From c2f7622fbbd818423bae7ef1e896a86f22a57e7f Mon Sep 17 00:00:00 2001 From: anti Date: Tue, 14 Apr 2026 00:17:57 -0400 Subject: [PATCH] fix: teardown --all now kills collector processes The collector kept streaming stale container IDs after a redeploy, causing new service logs to never reach decnet.log. Now _kill_api() also matches and SIGTERMs any running decnet.cli collect process. --- decnet/cli.py | 4 ++++ tests/test_cli.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/decnet/cli.py b/decnet/cli.py index 69a1866..47d9854 100644 --- a/decnet/cli.py +++ b/decnet/cli.py @@ -62,6 +62,10 @@ def _kill_api() -> None: console.print(f"[yellow]Stopping DECNET Mutator Watcher (PID {_proc.info['pid']})...[/]") os.kill(_proc.info['pid'], signal.SIGTERM) _killed = True + elif "decnet.cli" in _cmd and "collect" in _cmd: + console.print(f"[yellow]Stopping DECNET Collector (PID {_proc.info['pid']})...[/]") + os.kill(_proc.info['pid'], signal.SIGTERM) + _killed = True except (psutil.NoSuchProcess, psutil.AccessDenied): continue diff --git a/tests/test_cli.py b/tests/test_cli.py index 3cae81f..2cbebc5 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -337,9 +337,14 @@ class TestKillApi: "pid": 222, "name": "python", "cmdline": ["python", "decnet.cli", "mutate", "--watch"], } - mock_iter.return_value = [mock_uvicorn, mock_mutate] + mock_collector = MagicMock() + mock_collector.info = { + "pid": 333, "name": "python", + "cmdline": ["python", "-m", "decnet.cli", "collect", "--log-file", "/tmp/decnet.log"], + } + mock_iter.return_value = [mock_uvicorn, mock_mutate, mock_collector] _kill_api() - assert mock_kill.call_count == 2 + assert mock_kill.call_count == 3 @patch("psutil.process_iter") def test_no_matching_processes(self, mock_iter):