The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): `hermes gateway restart` without a service unit no longer bails on linger
Teknium7f487df266c9
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex abeaef358bb..12a3bec0daf 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -6148,7 +6148,10 @@ def _cmd_restart(args):except (subprocess.CalledProcessError, *swallow):pass- if supports_systemd_services():+ # Linger only explains a FAILED systemd unit restart. Without an installed unit the+ # detached run below is the restart; bailing here left `hermes gateway restart` a+ # silent exit-0 no-op on any Linux login session (Desktop read it as success).+ if kind == "systemd" and supports_systemd_services():linger_ok, _detail = get_systemd_linger_status()if linger_ok is not True:import getpassdiff --git a/tests/hermes_cli/test_gateway_restart_no_unit_linger.py b/tests/hermes_cli/test_gateway_restart_no_unit_linger.pynew file mode 100644index 00000000000..8008be9d3e1--- /dev/null+++ b/tests/hermes_cli/test_gateway_restart_no_unit_linger.py@@ -0,0 +1,52 @@+"""``hermes gateway restart`` without an installed service unit must actually restart.++Linger is a systemd-unit concern. With no unit installed the detached ``run_gateway`` IS the+restart, yet the linger check ran unconditionally and bailed with exit 0 on any Linux login+session whose linger is off — the Desktop/dashboard "Restart gateway" action then reported+success while nothing restarted and the saved credentials never loaded.+"""+from types import SimpleNamespace++import pytest++[email protected]_only+def test_restart_without_service_unit_runs_gateway_even_without_linger(monkeypatch):+ from hermes_cli import gateway as gw++ monkeypatch.setattr(gw, "_refuse_from_inside_gateway", lambda *a, **k: None)+ monkeypatch.setattr(gw, "_dispatch_via_service_manager_if_s6", lambda *a, **k: False)+ monkeypatch.setattr(gw, "_installed_service_kind_for", lambda windows: None)+ monkeypatch.setattr(gw, "supports_systemd_services", lambda: True)+ monkeypatch.setattr(gw, "get_systemd_linger_status", lambda *a, **k: (False, "Linger=no"))+ monkeypatch.setattr(gw, "stop_profile_gateway", lambda: True)+ monkeypatch.setattr(gw, "_wait_for_gateway_exit", lambda **k: None)+ started = []+ monkeypatch.setattr(gw, "run_gateway", lambda **k: started.append(k))++ gw._cmd_restart(SimpleNamespace(system=False, all=False))++ assert started, "no unit installed: restart must fall through to run_gateway, linger or not"++[email protected]_only+def test_restart_with_systemd_unit_still_reports_missing_linger(monkeypatch):+ from hermes_cli import gateway as gw++ monkeypatch.setattr(gw, "_refuse_from_inside_gateway", lambda *a, **k: None)+ monkeypatch.setattr(gw, "_dispatch_via_service_manager_if_s6", lambda *a, **k: False)+ monkeypatch.setattr(gw, "_installed_service_kind_for", lambda windows: "systemd")++ def _failing_service_call(*a, **k):+ import subprocess+ raise subprocess.CalledProcessError(1, ["systemctl"])++ monkeypatch.setattr(gw, "_service_call", _failing_service_call)+ monkeypatch.setattr(gw, "supports_systemd_services", lambda: True)+ monkeypatch.setattr(gw, "get_systemd_linger_status", lambda *a, **k: (False, "Linger=no"))+ started = []+ monkeypatch.setattr(gw, "run_gateway", lambda **k: started.append(k))++ gw._cmd_restart(SimpleNamespace(system=False, all=False))++ assert not started, "a broken unit must surface the linger hint, not double-start a detached gateway"