fix(cli): launchd KeepAlive unconditional restart (#37388)
Replace KeepAlive.SuccessfulExit=false dict with <key>KeepAlive</key><true/> so launchd restarts hermes-gateway on any exit, matching the documented drain-then-exit restart protocol used by --graceful-restart.
This commit is contained in:
@@ -2579,3 +2579,24 @@ class TestServiceWorkingDirIsStable:
|
||||
assert m, "plist has no WorkingDirectory entry"
|
||||
assert Path(m.group(1)).resolve() == home.resolve()
|
||||
assert "/.worktrees/" not in m.group(1)
|
||||
|
||||
def test_launchd_plist_keepalive_unconditional(self, tmp_path, monkeypatch):
|
||||
"""KeepAlive must be unconditional <true/> so the gateway restarts on clean exits.
|
||||
|
||||
Bug #37388: the old ``KeepAlive.SuccessfulExit = false`` dict form meant
|
||||
launchd would NOT restart after a zero-exit (e.g. ``gateway run --replace``
|
||||
causes the old instance to exit cleanly). Switching to the scalar
|
||||
``<key>KeepAlive</key><true/>`` makes launchd restart regardless of exit code.
|
||||
"""
|
||||
home = tmp_path / ".hermes"
|
||||
home.mkdir()
|
||||
monkeypatch.setattr(gateway_cli, "get_hermes_home", lambda: home)
|
||||
plist = gateway_cli.generate_launchd_plist()
|
||||
|
||||
# Scalar <true/> must be present immediately after the KeepAlive key
|
||||
assert "<key>KeepAlive</key>" in plist
|
||||
# The unconditional form
|
||||
assert "<key>KeepAlive</key>\n <true/>" in plist
|
||||
# The old conditional dict form must NOT appear
|
||||
assert "SuccessfulExit" not in plist
|
||||
assert "<key>KeepAlive</key>\n <dict>" not in plist
|
||||
|
||||
Reference in New Issue
Block a user