Zero-Downtime Cutover
readyHow NextDeploy achieves true zero-downtime releases on Linux VPS hosts using ephemeral port allocation, dual-stage TCP/HTTP health probes, atomic POSIX renameat() symlink swaps, and graceful connection draining.
Source reference: docs/internals/atomic-cutover.md, daemon/
Release Isolation & Ephemeral Port Allocation
Every nextdeploy ship builds into a brand-new immutable release directory:
/opt/nextdeploy/apps/my-app/releases/2026-11-23_14-20-00/
nextdeploydinspects active listening ports and assigns an idle internal loopback port (e.g.127.0.0.1:3002while the active release runs on:3001).- The incoming release boots inside its own systemd scope under its configured
cgroup v2memory limit. - A temporary symlink
current.tmpis created pointing at the new release directory.
Dual-Stage Health Probing
No live traffic shifts until both stages pass:
Stage 1: TCP Port Probe
Verifies the Node.js HTTP listener is bound and accepting connections — catching startup crashes, missing env vars, or syntax errors immediately.
Stage 2: HTTP Semantic Probe
Issues HTTP GET requests to deployment.healthcheck.path (default /api/health):
GET /api/health HTTP/1.1
Host: 127.0.0.1:3002
The deploy advances only when the endpoint returns 200 OK within timeout (default 5s) across retries attempts.
Atomic Symlink Swap & Connection Draining
The 4-Step Cutover Protocol:
nextdeploydvalidates and reloads Caddy's fragment (/etc/caddy/nextdeploy.d/<app>.caddy) pointing at the healthy candidate port.- Executes an atomic POSIX
os.Rename("current.tmp", "current")swap pointingcurrentto the new release directory. - Caddy immediately routes all new incoming requests to the new release on
:3002. - Stops the previous systemd unit (
SIGTERM,TimeoutStopSec=10s,KillMode=control-group), allowing in-flight requests to finish cleanly before terminating.
If health checks fail at any point, the active release stays untouched and zero users see an error.