hermes - ✅(Solved) Fix /restart shuts down gateway instead of restarting in Docker containers [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#25217Fetched 2026-05-14 03:47:59
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×4cross-referenced ×3

Root Cause

_handle_restart_command in gateway/run.py spawns a detached subprocess to restart the gateway when not running under systemd. In Docker, when the gateway exits, tini (PID 1) exits too, Docker stops the container, and the detached helper is killed before it can restart anything.

Fix Action

Fix

Detect Docker (/.dockerenv) and Podman (/run/.containerenv) containers and use the service restart path (exit code 75) instead. Combined with a restart policy (unless-stopped), Docker handles the restart.

PR fix notes

PR #25263: fix(gateway): restart via service in containers

Description (problem / solution / changelog)

Summary

Closes #25217.

/restart currently uses a detached helper whenever the gateway is not running under systemd. That works for a normal shell process, but not for Docker/Podman: once the gateway exits as PID 1, the container stops and the detached helper goes with it.

This routes container restarts through the existing service-restart path instead:

  • systemd: unchanged, detached=False, via_service=True
  • Docker/Podman: now also detached=False, via_service=True
  • plain non-container process: still uses the detached helper

The service path exits with the existing restart code, so a Docker/Podman restart policy such as unless-stopped or on-failure can bring the container back.

Tests

python -m py_compile gateway\run.py tests\gateway\test_restart_notification.py tests\gateway\test_restart_drain.py
python -m ruff check gateway\run.py tests\gateway\test_restart_notification.py tests\gateway\test_restart_drain.py
python -m pytest -o addopts='' tests\gateway\test_restart_notification.py tests\gateway\test_restart_drain.py::test_restart_command_while_busy_requests_drain_without_interrupt -q --basetemp .tmp\pytest -p no:cacheprovider

Result: 27 passed.

Note: the full tests\gateway\test_restart_drain.py file has an existing Windows-only failure in test_launch_detached_restart_command_uses_setsid: this Windows run enters the sys.executable -c detached watcher branch, while that test expects the POSIX setsid bash path.

Changed files

  • gateway/run.py (modified, +7/-6)
  • tests/gateway/test_restart_drain.py (modified, +1/-0)
  • tests/gateway/test_restart_notification.py (modified, +24/-0)

PR #25264: fix(gateway): detect Docker/Podman containers for /restart service path

Description (problem / solution / changelog)

Summary

The /restart gateway command only detected systemd (INVOCATION_ID) when choosing between the detached-subprocess and service-restart approaches. In Docker/Podman containers, the detached subprocess approach fails because the container stops when PID 1 exits, killing the helper before it can restart anything.

Problem

In a Docker container (e.g. nousresearch/hermes-agent:latest on Unraid):

  1. User sends /restart
  2. Gateway exits to spawn a detached restart helper
  3. tini (PID 1) exits because the gateway exited
  4. Docker stops the container
  5. The detached helper is killed before it can restart anything
  6. Gateway stays dead until manually restarted

Fix

Detect Docker (/.dockerenv) and Podman (/run/.containerenv) alongside systemd. In container environments, use the service restart path (exit code 75) instead of the detached subprocess approach. Combined with a restart policy (unless-stopped or on-failure), Docker/Podman handles the restart correctly.

_under_service = bool(
    os.environ.get("INVOCATION_ID")       # systemd
    or os.path.isfile("/.dockerenv")       # Docker
    or os.path.isfile("/run/.containerenv") # Podman
)

Testing

  • All 132 gateway restart-related tests pass

Files Changed

FileChange
gateway/run.pyAdded Docker/Podman detection to _under_service check

Closes #25217

Changed files

  • gateway/run.py (modified, +11/-1)
RAW_BUFFERClick to expand / collapse

Bug

When running the Hermes gateway in a Docker container, the /restart slash command shuts down the gateway permanently instead of restarting it.

Root Cause

_handle_restart_command in gateway/run.py spawns a detached subprocess to restart the gateway when not running under systemd. In Docker, when the gateway exits, tini (PID 1) exits too, Docker stops the container, and the detached helper is killed before it can restart anything.

Fix

Detect Docker (/.dockerenv) and Podman (/run/.containerenv) containers and use the service restart path (exit code 75) instead. Combined with a restart policy (unless-stopped), Docker handles the restart.

Environment

  • nousresearch/hermes-agent:latest on Unraid
  • Host networking, tini as PID 1
  • Restart policy must be set to unless-stopped or on-failure

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING