forked from p15670423/monkey
island: Log a warning if MongoDbProcess.stop() is erroniously called
This commit is contained in:
parent
e80ac4c943
commit
cc1865dc5b
|
@ -36,17 +36,21 @@ class MongoDbProcess:
|
||||||
logger.info("MongoDB launched successfully!")
|
logger.info("MongoDB launched successfully!")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self._process:
|
if not self._process:
|
||||||
logger.info("Terminating MongoDB process")
|
logger.warning("Failed to stop MongoDB process: No process found")
|
||||||
self._process.terminate()
|
return
|
||||||
try:
|
|
||||||
self._process.wait(timeout=TERMINATE_TIMEOUT)
|
logger.info("Terminating MongoDB process")
|
||||||
logger.info("MongoDB process terminated successfully")
|
self._process.terminate()
|
||||||
except subprocess.TimeoutExpired as te:
|
|
||||||
logger.warning(
|
try:
|
||||||
f"MongoDB did not terminate gracefully and will be forcefully killed: {te}"
|
self._process.wait(timeout=TERMINATE_TIMEOUT)
|
||||||
)
|
logger.info("MongoDB process terminated successfully")
|
||||||
self._process.kill()
|
except subprocess.TimeoutExpired as te:
|
||||||
|
logger.warning(
|
||||||
|
f"MongoDB did not terminate gracefully and will be forcefully killed: {te}"
|
||||||
|
)
|
||||||
|
self._process.kill()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _build_mongo_run_cmd(exec_path: str, db_dir: str) -> List[str]:
|
def _build_mongo_run_cmd(exec_path: str, db_dir: str) -> List[str]:
|
||||||
|
|
Loading…
Reference in New Issue