forked from p15670423/monkey
Island: Run AWS services on separate threads
AWS related services call AWS metadata service which might take a long time to timeout, that's why they are ran on a separate thread
This commit is contained in:
parent
0e1ffb4051
commit
d3c1ff89e9
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import uuid
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
from typing import Type
|
||||
|
||||
import flask_restful
|
||||
|
@ -104,8 +105,8 @@ def init_app_services(app):
|
|||
database.init()
|
||||
|
||||
# If running on AWS, this will initialize the instance data, which is used "later" in the
|
||||
# execution of the island.
|
||||
RemoteRunAwsService.init()
|
||||
# execution of the island. Run on a daemon thread since it's slow.
|
||||
Thread(target=RemoteRunAwsService.init, name="AWS check thread", daemon=True).start()
|
||||
|
||||
|
||||
def init_app_url_rules(app):
|
||||
|
|
|
@ -3,6 +3,7 @@ import json
|
|||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
|
||||
import gevent.hub
|
||||
from gevent.pywsgi import WSGIServer
|
||||
|
@ -131,7 +132,8 @@ def _configure_gevent_exception_handling(data_dir):
|
|||
def _start_island_server(
|
||||
should_setup_only: bool, config_options: IslandConfigOptions, container: DIContainer
|
||||
):
|
||||
populate_exporter_list()
|
||||
# AWS exporter takes a long time to load
|
||||
Thread(target=populate_exporter_list, name="Report exporter list", daemon=True).start()
|
||||
app = init_app(mongo_setup.MONGO_URL, container)
|
||||
|
||||
if should_setup_only:
|
||||
|
|
Loading…
Reference in New Issue