From 3e5f2b479121f7c65225d4ae1504508334c81f64 Mon Sep 17 00:00:00 2001 From: Wouter De Borger Date: Fri, 28 Jun 2024 13:25:33 +0200 Subject: [PATCH 1/4] Added alterantive childwatcher --- src/inmanta/server/bootloader.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/inmanta/server/bootloader.py b/src/inmanta/server/bootloader.py index c81d271246..a11ad06167 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,14 @@ 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 From e10d8206b07a909194f58377b2f4b6e64621fdb4 Mon Sep 17 00:00:00 2001 From: Wouter De Borger Date: Fri, 28 Jun 2024 13:38:34 +0200 Subject: [PATCH 2/4] fix pep8 --- src/inmanta/server/bootloader.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/inmanta/server/bootloader.py b/src/inmanta/server/bootloader.py index a11ad06167..1690651abe 100644 --- a/src/inmanta/server/bootloader.py +++ b/src/inmanta/server/bootloader.py @@ -108,7 +108,6 @@ async def start(self) -> None: 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 From 5a0d2dc06a255c3c20e972d1bada4af448985bea Mon Sep 17 00:00:00 2001 From: Wouter De Borger Date: Fri, 28 Jun 2024 13:55:46 +0200 Subject: [PATCH 3/4] added changelog --- changelogs/unreleased/agent_executor_6_5.yml | 5 +++++ src/inmanta/agent/_set_fork_server_process_name.py | 0 2 files changed, 5 insertions(+) create mode 100644 changelogs/unreleased/agent_executor_6_5.yml create mode 100644 src/inmanta/agent/_set_fork_server_process_name.py 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/agent/_set_fork_server_process_name.py b/src/inmanta/agent/_set_fork_server_process_name.py new file mode 100644 index 0000000000..e69de29bb2 From 1eaa30e42416e8551bb16f48fa9cf32e148ae19e Mon Sep 17 00:00:00 2001 From: Wouter De Borger Date: Mon, 1 Jul 2024 11:28:28 +0200 Subject: [PATCH 4/4] remove bad file --- src/inmanta/agent/_set_fork_server_process_name.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/inmanta/agent/_set_fork_server_process_name.py diff --git a/src/inmanta/agent/_set_fork_server_process_name.py b/src/inmanta/agent/_set_fork_server_process_name.py deleted file mode 100644 index e69de29bb2..0000000000