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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user