diff --git a/changelogs/unreleased/agent_executor_6_5.yml b/changelogs/unreleased/agent_executor_6_5.yml new file mode 100644 index 0000000000..fbddb13056 --- /dev/null +++ b/changelogs/unreleased/agent_executor_6_5.yml @@ -0,0 +1,5 @@ +description: Make the server work as a child reaper +change-type: patch +destination-branches: [master] +sections: + minor-improvement: The server now also cleans up zombie processes, which is convenient when running in a container diff --git a/src/inmanta/server/bootloader.py b/src/inmanta/server/bootloader.py index c81d271246..1690651abe 100644 --- a/src/inmanta/server/bootloader.py +++ b/src/inmanta/server/bootloader.py @@ -20,6 +20,7 @@ import importlib import logging import pkgutil +from asyncio import FastChildWatcher from collections.abc import Generator from pkgutil import ModuleInfo from types import ModuleType @@ -100,6 +101,13 @@ def __init__(self, configure_logging: bool = False) -> None: inmanta_logger_config.apply_options(inmanta_logging.Options()) async def start(self) -> None: + + # Use the fast child watcher + # It also servers as a reaper when the server is pid 1 in a container + childwatcher = FastChildWatcher() + childwatcher.attach_loop(asyncio.get_running_loop()) + asyncio.set_child_watcher(childwatcher) + db_wait_time: int = config.db_wait_time.get() if db_wait_time != 0: # Wait for the database to be up before starting the server