Skip to content

feat(gateway): restart manual profile gateways after update - #18178

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-2f48c480
May 1, 2026
Merged

feat(gateway): restart manual profile gateways after update#18178
teknium1 merged 3 commits into
mainfrom
hermes/hermes-2f48c480

Conversation

@teknium1

@teknium1 teknium1 commented May 1, 2026

Copy link
Copy Markdown
Contributor

Salvages #17982 by @quocanh261997 onto current main and adds a graceful-drain follow-up.

What

  • Map running manual gateway processes back to Hermes profiles via each profile's gateway.pid file.
  • During hermes update, relaunch profile-mapped manual gateways after terminating the old process via a detached Python watcher that waits for the old PID to exit, then spawns hermes [-p <profile>] gateway run --replace.
  • Drain via SIGUSR1 first, fall back to SIGTERM. Manual profile gateways now use the same _graceful_restart_via_sigusr1() path as systemd/launchd services, so in-flight agent runs finish instead of being SIGTERM'd. Watcher detects the clean exit and relaunches.
  • Keep the existing manual-restart warning for gateway PIDs that can't be mapped to a profile.
  • Update the updating guide.

Why

hermes update already restarts service-managed gateways. Manual profile gateways were only stopped, leaving users to restart each one by hand — painful with many profiles. The PR #17982 approach (PID-file mapping + detached watcher) is clean. Adding SIGUSR1 drain brings manual profile gateways to parity with service-managed ones for in-flight work.

Validation

scripts/run_tests.sh tests/hermes_cli/test_update_gateway_restart.py

43 passed (original 41 + 1 updated for graceful-drain path + 1 new for SIGTERM-fallback path).

E2E tested end-to-end against a real orphaned gateway (init-reparented, realistic production topology):

Before (#17982 baseline) After (this PR)
Unmapped manual gateway Stopped, user-restart msg Same — unchanged
Mapped manual gateway SIGTERM → watcher respawns SIGUSR1 drain (0.5s) → watcher respawns
SIGUSR1 unsupported/hangs n/a Falls back to SIGTERM
In-flight agent runs Cut mid-execution Finish cleanly via drain

Credit

Original PR #17982 by @quocanh261997. Their commit is preserved as the middle commit in this branch. Please rebase-merge to keep authorship attribution.

Closes #17982.

teknium1 and others added 3 commits April 30, 2026 19:52
The PR wired in a detached watcher that respawns manual profile gateways
after they exit.  Pair that with a SIGUSR1 graceful drain (same path
systemd/launchd use) so in-flight agent runs finish instead of getting
SIGTERM'd.  Fall back to SIGTERM if SIGUSR1 isn't wired or the gateway
doesn't exit within the drain budget — the watcher sees the exit and
relaunches either way.

Tested end-to-end against an orphaned gateway: graceful drain exits in
0.5s and the watcher fires the relaunch command.
@teknium1
teknium1 merged commit 9669126 into main May 1, 2026
10 of 12 checks passed
@teknium1
teknium1 deleted the hermes/hermes-2f48c480 branch May 1, 2026 03:00
@alt-glitch alt-glitch added comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/feature New feature or request labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants