Watchfire
Supervision
Supervision. States: starting (waiting for a group or global slot), running, paused, stopping,
stopped, backing_off, completed, failed, and standby (another process runs the agent; see "Several
processes"). The restart policy (Restart::Never, OnFailure (default),
Always) decides what happens when a run ends on its own; restarts wait an exponential backoff with full jitter
(a random delay up to initial × 2ⁿ, capped; a run of 60 s or more resets it). .max_restarts(n, per) marks the
agent failed after n restarts within per; .heartbeat_timeout(d) cancels a run that has not heartbeated
(ctx.heartbeat() or a ticker tick) for d (outcome stalled, restarted like a failure); .shutdown_timeout(d) (default 10 s) is how long a
cancelled run may take before it is dropped. A panic is caught and counts as a failure. Every run ends with exactly
one outcome: completed, failed, panicked, stopped, killed (did not stop in time), stalled (heartbeat
timeout) or interrupted (the process ended during the run; found on the next launch). Alerts (failed agents,
stalls) are logged at error level with the target smeltery_watchfire::alert.
Control from code. Agents (a service: app.service::<Agents>(), or a handler argument agents: Agents) has
list, status, start, stop, pause (stop and stay stopped until resume; kept in memory only, so a restart of
the process starts the agent again as autostart says), resume, restart, add,
remove, logs (the last 200 lines of ctx.log()), runs, emit and subscribe (status changes).