How it works
AllWatch is the parent, the target is the child. Every few seconds it looks at each configured target and puts it in one of four states.
Up
The process exists in /proc and its TCP port accepts a connection on 127.0.0.1. AllWatch resets the failure counter and does nothing.
Hung
The process exists but its port does not answer. AllWatch marks the target suspect at the first failed probe and waits 2 * POLL_SECONDS seconds, so a short slowdown does not cost a restart. If the port is still closed, ON_FREEZE decides: restart (the default) sends SIGTERM, waits about five seconds, sends SIGKILL if needed, and treats the target as failed; alert sends no signal, logs ALERTE GEL once, leaves the target running and logs RETABLI when the port answers again.
Crashed
The process is gone without a deliberate stop. AllWatch reads the exit code and restarts the target if its policy says so. For a target adopted after a supervisor restart, the exit code is not available: its disappearance is treated as a failure.
Quit
The target ended and its policy says to leave it alone, or an operator stop file was honoured, or the restart limit was reached. The PID file and the stop file are removed, and the target is no longer monitored until the supervisor restarts.
Policies
always: restart the target whenever it ends, even with exit code 0, unless a file<id>.stopexists in the state directory.on-failure: restart after a crash, or after a hang that AllWatch neutralized (ON_FREEZE=restart); leave the target stopped after an exit code 0. WithON_FREEZE=alert, a hung target is left running and is not restarted.transient: never restart the target.
Anti-loop window
If a target reaches MAX_RESTARTS restarts within RESTART_WINDOW seconds, AllWatch stops restarting it, writes ALERTE VERROU_CRITIQUE to the log and carries on with the other targets. The lock lasts until the supervisor restarts; the target is not retried automatically.