Deploying code updates to production should never require a maintenance window or risk throwing 502 Bad Gateway errors to active users. When running production Node.js applications on Virtual Private Servers (VPS), a standard pm2 restart all abruptly terminates every running worker process, dropping all active WebSocket connections and in-flight HTTP requests.
For CloudMaintain, we engineered an automated zero-downtime deployment pipeline combining Nginx upstream reverse proxying with PM2 rolling cluster reloads. Here is how we structured our deployment scripts to guarantee zero dropped packets during production releases.
The Anatomy of a Rolling Cluster Reload
Unlike a restart—which stops all workers before booting new ones—a rolling reload updates worker processes sequentially. PM2 signals Worker 0 with a SIGINT, waits for it to finish serving active requests, spawns a new instance running the updated code, verifies that the new worker is ready to receive traffic, and only then proceeds to reload Worker 1.
