Skip to content

fix(gateway): verify macOS launchd restart handoff#24954

Open
ken-zy wants to merge 1 commit into
NousResearch:mainfrom
ken-zy:fix/macos-launchd-gateway-restart
Open

fix(gateway): verify macOS launchd restart handoff#24954
ken-zy wants to merge 1 commit into
NousResearch:mainfrom
ken-zy:fix/macos-launchd-gateway-restart

Conversation

@ken-zy

@ken-zy ken-zy commented May 13, 2026

Copy link
Copy Markdown

Summary

  • Detect macOS launchd-managed gateway processes via XPC_SERVICE_NAME so /restart uses the service restart path instead of spawning a detached helper.
  • Make hermes gateway restart on launchd wait for a replacement gateway PID and gateway_state=running before reporting success.
  • Fall back to launchctl kickstart -k / bootstrap recovery if the graceful restart handoff is not verified.

Test Plan

  • python -m pytest tests/hermes_cli/test_gateway_service.py::TestLaunchdServiceRecovery tests/gateway/test_restart_drain.py -q -o 'addopts='
  • python -m py_compile gateway/run.py hermes_cli/gateway.py tests/gateway/test_restart_drain.py tests/hermes_cli/test_gateway_service.py
  • git diff --check -- gateway/run.py hermes_cli/gateway.py tests/gateway/test_restart_drain.py tests/hermes_cli/test_gateway_service.py

Notes

A broader local run of tests/hermes_cli/test_gateway_service.py tests/gateway/test_restart_drain.py on macOS hit pre-existing systemd-only tests that call _preflight_user_systemd() and fail because macOS has no user systemd session. The launchd-specific class and restart-drain tests pass.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists labels May 13, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #19940 — same XPC_SERVICE_NAME launchd detection fix for /restart. #24898 was already flagged as a duplicate of #19940. This PR extends the scope (adds restart handoff verification and launchctl kickstart -k fallback) but the core fix overlaps with #19940.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants