diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 7cb34a5a3..97f7dfca1 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -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): diff --git a/monkey/monkey_island/cc/server_setup.py b/monkey/monkey_island/cc/server_setup.py index 399b8ebc9..c883d70db 100644 --- a/monkey/monkey_island/cc/server_setup.py +++ b/monkey/monkey_island/cc/server_setup.py @@ -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: