← back to Handbag Auth Nextjs

auction-viewer/config/pm2.ecosystem.config.js

59 lines

module.exports = {
  apps: [{
    name: 'auction-viewer',
    script: './server.js',
    cwd: '/root/Projects/handbag-auth-nextjs/auction-viewer',
    instances: 1,
    autorestart: true,
    watch: false,
    max_memory_restart: '500M',
    env: {
      NODE_ENV: 'production',
      PORT: 7500
    },
    error_file: '/root/Projects/handbag-auth-nextjs/logs/auction-viewer-error.log',
    out_file: '/root/Projects/handbag-auth-nextjs/logs/auction-viewer-out.log',
    log_file: '/root/Projects/handbag-auth-nextjs/logs/auction-viewer-combined.log',
    time: true,
    merge_logs: true,
    log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
    max_restarts: 10,
    min_uptime: '10s',
    listen_timeout: 10000,
    kill_timeout: 5000,
    wait_ready: true,
    shutdown_with_message: true,

    // Advanced PM2 features
    exp_backoff_restart_delay: 100,

    // Health check configuration
    health_check: {
      url: 'http://45.61.58.125:7500/health',
      interval: 30000,
      timeout: 5000
    },

    // Monitoring
    pmx: true,
    vizion: false,
    post_update: ['npm install'],

    // Automation
    cron_restart: '0 4 * * *',  // Daily restart at 4am for memory cleanup

    // Resource limits
    max_memory_restart: '500M',

    // Graceful restart/reload
    kill_timeout: 5000,
    listen_timeout: 10000,

    // Logging
    merge_logs: true,

    // Source control (if using git)
    versioning: false
  }]
};