Skip to content

The agent that grows with you

fix(dump): report a supervised gateway without a scannable PID as running (#125390)

teknium12dc8f7715ab3
diff --git a/hermes_cli/dump.py b/hermes_cli/dump.py
index a19c0ba5682..426450939ad 100644
--- a/hermes_cli/dump.py
+++ b/hermes_cli/dump.py
@@ -105,7 +105,9 @@ def _gateway_status() -> str:
snapshot = get_gateway_runtime_snapshot()
if snapshot.running:
mode = "manual" if snapshot.has_process_service_mismatch else snapshot.manager
- return f"running ({mode}, pid {snapshot.gateway_pids[0]})"
+ # A supervised gateway may have no scannable PID (s6 `python -c` launcher, #125390).
+ pid = f", pid {snapshot.gateway_pids[0]}" if snapshot.gateway_pids else ""
+ return f"running ({mode}{pid})"
return f"stopped ({snapshot.manager})"
except Exception:
return "unknown" if sys.platform.startswith(("linux", "darwin")) else "N/A"
diff --git a/tests/hermes_cli/test_dump_gateway_status.py b/tests/hermes_cli/test_dump_gateway_status.py
new file mode 100644
index 00000000000..7871cb78724
--- /dev/null
+++ b/tests/hermes_cli/test_dump_gateway_status.py
@@ -0,0 +1,14 @@
+"""``hermes dump`` gateway line for a supervised gateway with no scannable PID (#125390)."""
+
+from __future__ import annotations
+
+from hermes_cli.dump import _gateway_status
+from hermes_cli.gateway import GatewayRuntimeSnapshot
+
+
+def test_s6_supervised_gateway_without_pid_is_running_not_unknown(monkeypatch):
+ """s6 service up, empty process scan: ``running (...)`` — not an IndexError swallowed into ``unknown``."""
+ snapshot = GatewayRuntimeSnapshot(
+ manager="s6 (container supervisor)", service_installed=True, service_running=True, gateway_pids=())
+ monkeypatch.setattr("hermes_cli.gateway.get_gateway_runtime_snapshot", lambda: snapshot)
+ assert _gateway_status() == "running (s6 (container supervisor))"