Skip to content

PM2 Deployment

PM2 is a production process manager for Node.js applications.

Prerequisites

bash
npm install -g pm2

Configuration

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.js

Manage

bash
pm2 status
pm2 logs better-reports
pm2 restart better-reports
pm2 stop better-reports

Startup Script

bash
pm2 startup
pm2 save

Design and Dev by David Lam