The deploy script already had a rollback. Switch the current symlink, restart the systemd unit, poll /healthz , and if that fails, switch back and restart again. On paper that's a safe deploy.
In practice, every broken release still produced an outage. The reverse proxy returned 502 from the moment the old process stopped until the rollback had brought it back β up to about 35 seconds in the worst case, and a few seconds even after the health check learned to fail fast . A post-switch health check can't prevent that. It runs after the damage, and its only job is to bound it.
The fix was to move the question "does this release start?" to before the switch, and to ask it against the real data.
TL;DR: Before touching current , the deploy now copies the live SQLite database with VACUUM INTO , starts the new release on a free localhost port against that copy with a throwaway config and session secret and every outbound job disabled, and waits for /healthz .β¦