hermes - 💡(How to fix) Fix cron: Cron jobs inherit gateway cgroup, cannot safely restart the service

Official PRs (…)
ON THIS PAGE

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…

Fix Action

Workaround

Instead of systemctl restart inside a cron job, schedule a delayed restart from outside the cgroup:

systemd-run --user --on-active=10 --unit=hermes-gateway-restart systemctl --user restart hermes-gateway

Code Example

May 07 01:01:38 WARNING: Shutdown diagnostic - other hermes processes running:
  brian  1477623  /usr/bin/bash -c "systemctl --user restart hermes-gateway"
  brian  1477625  systemctl --user restart hermes-gateway
...
May 07 01:03:08 systemd: Killing process 1477729 (bash) with signal SIGKILL
May 07 01:03:08 systemd: Killing process 1477731 (systemctl) with signal SIGKILL
May 07 01:03:08 systemd: Failed with result timeout

---

systemd-run --user --on-active=10 --unit=hermes-gateway-restart systemctl --user restart hermes-gateway
RAW_BUFFERClick to expand / collapse

Bug Description

When the Hermes gateway runs cron jobs, those jobs execute as child processes of the gateway and live in the same systemd control group. If a cron job attempts to restart the gateway via systemctl --user restart hermes-gateway, the restart command itself is in the gateway's control group. When systemd stops the service during the restart sequence, it kills the entire cgroup - including the running restart command - before the new gateway instance can start.

Steps to Reproduce

  1. Run the Hermes gateway as a systemd user service (Restart=always)
  2. Schedule a cron job that runs systemctl --user restart hermes-gateway
  3. Cron job fires - it is a child of the gateway process, inside the same cgroup
  4. systemctl restart sends SIGTERM to the gateway
  5. systemd stops the service and kills the cgroup (includes the running restart command)
  6. The new gateway instance never starts
  7. Service stays failed indefinitely

Actual Behavior

May 07 01:01:38 WARNING: Shutdown diagnostic - other hermes processes running:
  brian  1477623  /usr/bin/bash -c "systemctl --user restart hermes-gateway"
  brian  1477625  systemctl --user restart hermes-gateway
...
May 07 01:03:08 systemd: Killing process 1477729 (bash) with signal SIGKILL
May 07 01:03:08 systemd: Killing process 1477731 (systemctl) with signal SIGKILL
May 07 01:03:08 systemd: Failed with result timeout

The bash and systemctl processes (the cron job's restart command) are killed alongside the main gateway process.

Expected Behavior

The cron subsystem should spawn jobs in their own cgroup or process group so they can safely interact with systemd. Suggested solutions:

  1. Spawn cron jobs via systemd-run so each job gets its own transient systemd unit and cgroup, isolated from the gateway
  2. Add a SIGUSR1 handler to the gateway that performs an inline graceful restart (re-exec) without involving systemd
  3. Add a --restart-gateway flag to the gateway CLI that defers the restart via systemd-run internally

Workaround

Instead of systemctl restart inside a cron job, schedule a delayed restart from outside the cgroup:

systemd-run --user --on-active=10 --unit=hermes-gateway-restart systemctl --user restart hermes-gateway

Environment

  • Linux (Ubuntu 24.04)
  • systemd v255
  • Gateway as systemd user service with Restart=always

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

hermes - 💡(How to fix) Fix cron: Cron jobs inherit gateway cgroup, cannot safely restart the service