hephaestus/docs/how-to/self-update/service-respawn-on-clean-exit.md
Erich Blume e6524fddbb
All checks were successful
Build / validate (pull_request) Successful in 5m23s
C2(hephd-self-update): plan add goal + prerequisite cards for hephd self-update
Kick off the C2 Mikado chain for an opt-in (default-off) hephd
self-update mode (forge-poll -> cargo install from tag -> self-restart).
Goal card plus eight prerequisite cards, indexed from how-to.md:

  release-poll-version-check, self-update-opt-in-flag (leaves)
    -> self-update-poll-loop                 (notify-only core)
  service-env-forge-access (leaf, the cargo/forge blocker)
    + self-update-poll-loop -> cargo-install-from-tag
  service-respawn-on-clean-exit (leaf, systemd Restart=always)
    + cargo-install-from-tag -> self-restart-after-update
  verify-hub-dropout-resilience (leaf, lock in the base-case guarantee)

Grounded in research of hephd's sync loop, daemon lifecycle, the
launchd/systemd service templates, and the forge releases API.
Captured from Hephaestus task 01KTA2NSNRYT902HC3VRW00S1J.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 13:20:46 -07:00

1.2 KiB

title modified tags status requires
Service respawn on clean exit 2026-06-04
how-to
active

Service respawn on clean exit

For "self-restart" to mean "exit and let the manager bring up the new binary", both service managers must respawn hephd after a clean (exit code 0) shutdown. Templates live in crates/heph/src/service.rs.

Current state (from research)

  • launchd (macOS): plist has KeepAlive = true → already respawns on clean exit. No change needed.
  • systemd (Linux): unit is Restart=on-failure → a clean exit (code 0) does not respawn. Self-restart would silently stop the daemon.

Deliverables

  • Change the systemd unit template to Restart=always (with a small RestartSec) so a deliberate clean exit is respawned.
  • Note in install/upgrade docs that already-installed services must be reinstalled (heph daemon re-generates the unit) to pick up the new policy; otherwise self-restart won't work on existing Linux installs.

Done when

On both platforms, a hephd that calls exit(0) is brought back up by the service manager. Pairs with self-restart-after-update. Part of hephd-self-update.