// PM2 process manager config
// Install: npm install -g pm2
// Start:   pm2 start ecosystem.config.js
// Status:  pm2 status
// Logs:    pm2 logs skeet-server
// Restart: pm2 restart skeet-server
// Stop:    pm2 stop skeet-server
// Auto-start on boot: pm2 startup && pm2 save

module.exports = {
  apps: [{
    name: 'skeet-server',
    script: 'server.js',
    cwd: __dirname,
    env: {
      NODE_ENV: 'production',
      PORT: 3000
    },
    // Restart if memory exceeds 200MB
    max_memory_restart: '200M',
    // Restart if it crashes
    autorestart: true,
    // Max 5 restarts in 60 seconds, then stop
    max_restarts: 5,
    min_uptime: '60s',
    // Log settings
    log_date_format: 'YYYY-MM-DD HH:mm:ss',
    error_file: './logs/error.log',
    out_file: './logs/out.log',
    merge_logs: true
  }]
};
