no downtime deploy
scattered notes on zero downtime deploys for personal projects.
- build release binary
- scp file to server with a unique name
- run the server on the
down
port - wait for the server to be ready
- switch the caddy config to point to the new server
- reload caddy
- kill the old server
- Use
EnvironmentFile
on systemd to load env vars - Set
LimitNOFILE=65535
on the service to avoid open limit StandardError=journal
StandardOutput=journal
sojournalctl
can see logs- Use postgres, DO takes regular backups, maintenance is low
- Nginx has password-protected endpoints, use to hide app logs
- Nginx can cache static assets + APIs that barely change
Caddy Health checks and lb_retries can fix downtime Flip the proxy port after the new server is up Reload Caddy
my.domain.com {
encode gzip
reverse_proxy http://localhost:8001 {
lb_try_duration 60s
fail_duration 1s
health_uri /healthz
health_interval 5s
}
}