refactor: simplify _get_service_pids — dedupe systemd scopes, fix self-import, harden launchd parsing

- Loop over user/system scope args instead of duplicating the systemd block
- Call get_launchd_label() directly instead of self-importing from hermes_cli.gateway
- Validate launchd output by checking parts[2] matches expected label (skip header)
- Add race-condition assumption docstring
This commit is contained in:
kshitijk4poor
2026-04-06 10:09:04 +05:30
committed by Teknium
parent a2a9ad7431
commit d3d5b895f6
2 changed files with 34 additions and 56 deletions

View File

@@ -662,6 +662,7 @@ class TestGetServicePids:
def test_returns_launchd_pid(self, monkeypatch):
monkeypatch.setattr(gateway_cli, "is_linux", lambda: False)
monkeypatch.setattr(gateway_cli, "is_macos", lambda: True)
monkeypatch.setattr(gateway_cli, "get_launchd_label", lambda: "ai.hermes.gateway")
def fake_run(cmd, **kwargs):
joined = " ".join(str(c) for c in cmd)