island: Inline method _start_mongodb_process() in MongoDbProcess

This commit is contained in:
Mike Salvatore 2021-06-02 15:18:07 -04:00
parent 1e21446bb8
commit 3b958f5a61
1 changed files with 11 additions and 14 deletions

View File

@ -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]