diff --git a/monkey/monkey_island/cc/setup/mongo/mongo_db_process.py b/monkey/monkey_island/cc/setup/mongo/mongo_db_process.py index 96341b7d8..3ada3bdb1 100644 --- a/monkey/monkey_island/cc/setup/mongo/mongo_db_process.py +++ b/monkey/monkey_island/cc/setup/mongo/mongo_db_process.py @@ -23,7 +23,17 @@ class MongoDbProcess: self._process = None def start(self): - self._start_mongodb_process() + logger.info("Starting MongoDb process.") + + mongo_run_cmd = MongoDbProcess._build_mongo_launch_cmd(MONGO_EXECUTABLE_PATH, self._db_dir) + logger.info(f"Mongodb will be launched with command: {' '.join(mongo_run_cmd)}.") + + mongo_log_path = os.path.join(self._logging_dir, MONGO_LOG_FILENAME) + logger.info(f"Mongodb log will be available at {mongo_log_path}.") + + with open(mongo_log_path, "w") as log: + self._process = subprocess.Popen(mongo_run_cmd, stderr=subprocess.STDOUT, stdout=log) + logger.info("MongoDb launched successfully!") def stop(self): if self._process: @@ -38,19 +48,6 @@ class MongoDbProcess: ) self._process.kill() - def _start_mongodb_process(self): - logger.info("Starting MongoDb process.") - - mongo_run_cmd = MongoDbProcess._build_mongo_launch_cmd(MONGO_EXECUTABLE_PATH, self._db_dir) - logger.info(f"Mongodb will be launched with command: {' '.join(mongo_run_cmd)}.") - - mongo_log_path = os.path.join(self._logging_dir, MONGO_LOG_FILENAME) - logger.info(f"Mongodb log will be available at {mongo_log_path}.") - - with open(mongo_log_path, "w") as log: - self._process = subprocess.Popen(mongo_run_cmd, stderr=subprocess.STDOUT, stdout=log) - logger.info("MongoDb launched successfully!") - @staticmethod def _build_mongo_launch_cmd(exec_path: str, db_dir: str) -> List[str]: return [exec_path, DB_DIR_PARAM, db_dir]