Repository navigation
Description
Summary
On Docker (s6-overlay) deployments, after a container restart or image upgrade (docker compose up -d --force-recreate), the gateway does not auto-start. Messaging channels (WeChat/Telegram/etc.) go silently dark while the CLI still works. Root cause: every shutdown path — including the SIGTERM a supervisor/container sends on stop/upgrade — unconditionally persists gateway_state=stopped, and container_boot then treats that as an explicit user stop and refuses to bring the gateway back up.
Environment
- Hermes Agent 0.16.0, official Docker image (s6-overlay),
hermes dashboard+ gateway in one container,HERMES_HOMEon a persistent volume.
Repro
- Gateway running (
gateway_state=running). docker compose up -d --force-recreate(or any image upgrade / container restart) sends SIGTERM to the gateway process.- New container boots;
container_bootreadsgateway_state=stopped, registers the s6 service down → gateway never starts. - Messaging channels stay down;
hermes gateway statusshows "not running". No error is surfaced to the user.
Root cause
gateway/run.py _stop_impl() ends with an unconditional:
self._update_runtime_status("stopped", self._exit_reason) # run.py:5955 (0.16.0)This runs for every shutdown, including signal-initiated ones (SIGTERM from s6/Docker on restart/upgrade). hermes_cli/container_boot.py intentionally preserves an explicit stopped across restarts ("explicit stopped/failed states keep winning") to respect a user who ran hermes gateway stop. But it cannot distinguish:
- user-requested stop (
hermes gateway stop) — should persiststopped; vs - signal/container-initiated stop (SIGTERM on upgrade/restart) — desired state is still "running"; should auto-recover.
Both currently write stopped, so a routine upgrade is misread as a deliberate stop and the gateway stays down.
Relationship to #39381
This sits one layer above the s6 down-marker issue (#39381): container_boot decides whether to lay down the s6 down marker based on this gateway_state. Fixing the state semantics prevents the upgrade case from ever reaching the down-marker path.
Possible fixes (seeking direction before a PR)
- In the shutdown path, only persist
stoppedfor user-requested stops; for signal-initiated shutdown, leave the desired state untouched (or write a distinctinterrupted/crashedruntime state thatcontainer_boottreats as "recover"). - Or have
container_bootdistinguish "process was signaled/interrupted" from "user explicitly stopped". - Or track a persistent
desired_state(running/stopped), set only by explicit start/stop commands, separate from the transient runtime status.
Happy to implement once there's agreement on the preferred shape.
Activity
docs(docker): clarify gateway autostart distinguishes operator-stop f…
test(docker): real-restart autostart E2E for #42675
fix(gateway): auto-start after container restart via planned-stop mar…
benbarclay commentedon Jun 10, 2026
Fixed by #43236 (merged,
5cf6e28).Root cause confirmed exactly as described:
_stop_implingateway/run.pyended with an unconditional_update_runtime_status("stopped"), so the SIGTERM s6/Docker sends ondocker compose up -d --force-recreatepersistedgateway_state=stopped.container_boot.pythen read that and registered the slot down (onlyrunningis in_AUTOSTART_STATES), so the gateway silently stayed dark after every container restart.The fix reuses the existing planned-stop marker primitive rather than inferring intent from the signal: an operator-initiated stop (
hermes gateway stop, systemd/launchd ExecStop, the s6 stop path, Ctrl+C) writes a marker before signalling and persistsstopped; an unmarked SIGTERM (container/s6 restart, OOM, bare kill) is classified signal-initiated and persistsrunning, so the reconciler auto-starts it on the next boot.S6ServiceManager.stop()now also writes the marker befores6-svc -dso in-container explicit stops are correctly classified.Verified end-to-end: a live gateway killed by a real
docker restartnow auto-starts (prior_state=running action=started); the same test fails against a pre-fix image (prior_state=stopped action=registered). Docs updated indocker.mdto spell out the operator-stop vs. container-kill distinction.fix(gateway): auto-start after container restart via planned-stop mar…
fix(gateway): auto-start after container restart via planned-stop mar…
fix(gateway): auto-start after container restart via planned-stop mar…
9 remaining items
fix(container-boot): autostart a gateway stranded in 'draining' state
fix(gateway): auto-start after container restart via planned-stop mar…
fix(container-boot): autostart a gateway stranded in 'draining' state
fix(gateway): auto-start after container restart via planned-stop mar…
fix(gateway): auto-start after container restart via planned-stop mar…
fix(container-boot): autostart a gateway stranded in 'draining' state
fix(gateway): auto-start after container restart via planned-stop mar…
fix(container-boot): autostart a gateway stranded in 'draining' state
fix(container-boot): autostart a gateway stranded in 'draining' state
fix(gateway): auto-start after container restart via planned-stop mar…
fix(container-boot): autostart a gateway stranded in 'draining' state
fix(gateway): auto-start after container restart via planned-stop mar…
fix(container-boot): autostart a gateway stranded in 'draining' state