# Zero-downtime deploys

Every live deploy goes through a drain-and-swap sequence: the new container starts, passes its health check, takes over traffic via an atomic Caddy route swap, and the old container is stopped only once the post-deploy canary settles — so if the canary fails, the previous version still exists and Percher rolls the route straight back to it.

A 60-second canary monitor probes the new version after the swap. If two probes return 5xx in a row, Percher rolls back: it restores the previous version's upstream and the access settings that version was serving under — password protection, visibility, redirects, response headers and rate limit all go back with it — stops the failed container, and marks the deploy failed. A rollback never leaves a protected app public because the deploy that failed asked for public.

When the previous containers are already gone — they crashed on their own, or an operator removed them — there is nothing to restore, so Percher leaves the new container running instead of taking the app down. It does the same on the rarer occasions when it can restore the route but cannot safely finish the bookkeeping: nothing that might still be serving is destroyed on the strength of a rollback Percher could not complete. The deploy is marked failed either way, and the row on the deploy timeline says which of them happened — read the message on it rather than the heading, which only has two words to work with. The dashboard shows this as a stepper (Build, Start, Health check, Swap, Canary, Live) with a rollback row if the canary fired.

The canary window and automatic rollback are settings of the Percher instance, not of your app: on percher.app the window is 60 seconds and auto-rollback is on for every app. Setting `PERCHER_CANARY_AUTO_ROLLBACK`, `PERCHER_CANARY_WINDOW_MS` or `PERCHER_DRAIN_GRACE_MS` as an app environment variable has no effect; they apply only to a self-hosted Percher API.

Post-deploy screenshots (preview): once a deploy is live, Percher can capture a screenshot of your app and attach it to that deploy — surfaced as a `screenshotUrl` on the deploy result. It's a preview feature, off by default, and strictly best-effort: a screenshot never delays or fails a deploy. Only public apps are captured; a password-protected or private app is skipped (Percher never logs in to take the shot). The capture hits your app's public URL through a locked-down headless browser that can only reach your own app's hosts — it can't be pointed at anything internal.

Full guide: https://percher.app/docs/graceful-deploys
