diff options
author | Devaev Maxim <[email protected]> | 2020-12-02 15:35:11 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-12-02 15:35:11 +0300 |
commit | 7debaa677663fa22d00df1decd932f53b97786e9 (patch) | |
tree | caf3123cc90167699852080e4c3d82d599dc13b4 /kvmd/aioproc.py | |
parent | 5bc868662a7ef2b8959a04e6678c512797ebd7be (diff) |
refactoring
Diffstat (limited to 'kvmd/aioproc.py')
-rw-r--r-- | kvmd/aioproc.py | 10 |
1 files changed, 10 insertions, 0 deletions
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 |