From 7debaa677663fa22d00df1decd932f53b97786e9 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Wed, 2 Dec 2020 15:35:11 +0300 Subject: refactoring --- kvmd/aioproc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'kvmd/aioproc.py') diff --git a/kvmd/aioproc.py b/kvmd/aioproc.py index b4b84ea4..6c5fd6be 100644 --- a/kvmd/aioproc.py +++ b/kvmd/aioproc.py @@ -30,6 +30,8 @@ from typing import List import setproctitle +from .logging import get_logger + # ===== async def run_process(cmd: List[str], err_to_null: bool=False) -> asyncio.subprocess.Process: # pylint: disable=no-member @@ -71,3 +73,11 @@ async def log_stdout_infinite(proc: asyncio.subprocess.Process, logger: logging. def rename_process(suffix: str, prefix: str="kvmd") -> None: setproctitle.setproctitle(f"{prefix}/{suffix}: {setproctitle.getproctitle()}") + + +def settle(name: str, suffix: str, prefix: str="kvmd") -> logging.Logger: + logger = get_logger(1) + logger.info("Started %s pid=%d", name, os.getpid()) + os.setpgrp() + rename_process(suffix, prefix) + return logger -- cgit v1.2.3