mirror of
https://github.com/storytold/autocraft.git
synced 2026-11-27 16:49:34 +01:00
Two copies of the runner or of the periodic chores can run on one Postgres database: the copy that holds the role's session-level advisory lock leads, the other waits as a standby and takes over when the leader's session ends. A new leader moves the role's epoch and fences its writes, and those of its jobs, to it: every write transaction checks the epoch after the writer lock, so writes of a leader that lost its lock fail. The old leader kills its jobs and exits when its lock connection fails or a check of the lock fails. A standby runner answers /readyz with 503; /healthz/checks gains runner-leader and periodic-leader. The periodic loop moves to deploy/periodic.sh, run by autocraft-server periodic.