How do I rollback a deployment?
Option 1: git revert HEAD or git reset --hard <commit-hash>, then npm install and pm2 reload. Option 2: Keep a previous directory (devtinder-backend-prev) and switch PM2 to it: pm2 stop, pm2 delete, cd to prev directory, pm2 start.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Nginx and PM2 Deployment Workflow Complete Guide to Node.js Production Setup
Initial setup: install Node.js, PM2, Nginx, clone project, configure .env, start with PM2, configure Nginx as reverse proxy, add SSL with Let's Encrypt. Regular deployments: git pull, npm install, pm2 reload (zero downtime). Use automated scripts and ecosystem.config.js for complex setups.
Use pm2 reload devtinder-api instead of pm2 restart. In cluster mode, PM2 reloads workers one at a time, keeping the app available throughout. No requests are dropped during the reload.
A JavaScript file (ecosystem.config.js) that defines app configuration: name, script, instances (max for all cores), exec_mode (cluster), max_memory_restart, environment variables, and log file paths. Start with pm2 start ecosystem.config.js.
Still have questions?
Browse all our FAQs or reach out to our support team
