PM2 Deployment
PM2 is a production process manager for Node.js applications.
Prerequisites
bash
npm install -g pm2Configuration
Better Reports includes an ecosystem.config.js:
js
module.exports = {
apps: [{
name: 'better-reports',
script: 'src/server.mjs',
env: {
NODE_ENV: 'production',
PORT: 3000,
},
instances: 1,
exec_mode: 'fork',
max_restarts: 10,
restart_delay: 5000,
}]
}Start
bash
pm2 start ecosystem.config.jsManage
bash
pm2 status
pm2 logs better-reports
pm2 restart better-reports
pm2 stop better-reportsStartup Script
bash
pm2 startup
pm2 save