What happened
When the agent runs systemctl --user restart hermes-gateway via the terminal tool, the command is a child process of the gateway itself. When systemd delivers SIGTERM to the gateway's main PID, it also kills the systemctl restart command mid-execution. The command that was supposed to restart the gateway gets killed by the very restart it initiated.
Why this matters
The gateway has a guard for hermes gateway restart ("Refusing to restart the gateway from inside the gateway process") but this only blocks the Hermes CLI command. Raw systemctl --user restart bypasses the guard and creates a deadlock.
Reproduction
- Start a session with the gateway running as a systemd service
- Have the agent run:
systemctl --user restart hermes-gateway
- The gateway receives SIGTERM, starts draining active sessions
- The
systemctl restart command (a child of the gateway) gets killed before it can complete
- If the restart command is killed mid-execution, systemd may not restart the service at all — or it may do so after a long delay
Observed behavior
09:27:29 agent runs "hermes gateway restart" → blocked by guard (correct)
09:27:33 agent runs "systemctl --user restart hermes-gateway" → bypasses guard
09:27:33 gateway receives SIGTERM, begins draining
09:28:34 drain times out after 60s — agent session still active
09:28:36 gateway exits with code 1
09:28:37 systemd journal: "Failed to kill control group ... Invalid argument"
09:34:48 gateway finally restarts (6+ minute gap!)
The 6-minute gap between stop and restart left Telegram, Discord, WhatsApp, and all cron jobs completely dead during that window.
Environment
- Hermes Agent v0.15.1
- systemd user service with
KillMode=mixed, Restart=always
- Linux (kernel 6.8.0-124-generic)
Suggested fix
Either:
- Block raw
systemctl restart via the same guard that blocks hermes gateway restart
- Or detect that the restart command is a child of the gateway and defer it (e.g., schedule via
systemd-run --user --on-active=10 to run from a separate cgroup)
- The existing guard could be extended to detect
systemctl commands targeting the hermes-gateway unit
What happened
When the agent runs
systemctl --user restart hermes-gatewayvia the terminal tool, the command is a child process of the gateway itself. When systemd delivers SIGTERM to the gateway's main PID, it also kills thesystemctl restartcommand mid-execution. The command that was supposed to restart the gateway gets killed by the very restart it initiated.Why this matters
The gateway has a guard for
hermes gateway restart("Refusing to restart the gateway from inside the gateway process") but this only blocks the Hermes CLI command. Rawsystemctl --user restartbypasses the guard and creates a deadlock.Reproduction
systemctl --user restart hermes-gatewaysystemctl restartcommand (a child of the gateway) gets killed before it can completeObserved behavior
The 6-minute gap between stop and restart left Telegram, Discord, WhatsApp, and all cron jobs completely dead during that window.
Environment
KillMode=mixed,Restart=alwaysSuggested fix
Either:
systemctl restartvia the same guard that blockshermes gateway restartsystemd-run --user --on-active=10to run from a separate cgroup)systemctlcommands targeting thehermes-gatewayunit