Create data_dir before logger is set up

This commit is contained in:
Shreya 2021-05-14 17:08:55 +05:30
parent 82463416f8
commit 808e86df1a
2 changed files with 8 additions and 7 deletions

View File

@ -10,6 +10,12 @@ import os # noqa: E402
from monkey_island import config_loader # noqa: E402
from monkey_island.cc.server_utils.island_logger import setup_logging # noqa: E402
def create_data_dir(data_dir):
if not os.path.isdir(data_dir):
os.makedirs(data_dir, mode=0o700)
if "__main__" == __name__:
island_args = parse_cli_args()
@ -23,6 +29,8 @@ if "__main__" == __name__:
config = config_loader.load_server_config_from_file(server_config_path)
create_data_dir(config["data_dir"])
setup_logging(config["data_dir"], config["log_level"])
except OSError as ex:

View File

@ -41,8 +41,6 @@ def main(
):
logger.info("Starting bootloader server")
create_data_dir(data_dir)
env_singleton.initialize_from_file(server_config_filename)
initialize_encryptor(data_dir)
initialize_services(data_dir)
@ -57,11 +55,6 @@ def main(
bootloader_server_thread.join()
def create_data_dir(data_dir):
if not os.path.isdir(data_dir):
os.makedirs(data_dir, mode=0o700)
def start_island_server(should_setup_only):
mongo_url = os.environ.get("MONGO_URL", env_singleton.env.get_mongo_url())
wait_for_mongo_db_server(mongo_url)