// PM2 ecosystem config — used for direct Node.js deployments (no Docker).
// Deploy: pm2 start scripts/ecosystem.config.js --env production
// Reload:  pm2 reload bill-tracker
// Logs:    pm2 logs bill-tracker

module.exports = {
  apps: [
    {
      name:        'bill-tracker',
      script:      'server.js',
      cwd:         '/opt/bill-tracker',
      instances:   1,
      exec_mode:   'fork',
      watch:       false,
      env_production: {
        NODE_ENV:    'production',
        PORT:        3000,
        DB_PATH:     '/opt/bill-tracker/data/db/bills.db',
        BACKUP_PATH: '/opt/bill-tracker/data/backups',
      },
      error_file:  '/opt/bill-tracker/data/logs/error.log',
      out_file:    '/opt/bill-tracker/data/logs/out.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      max_restarts: 10,
      restart_delay: 5000,
    },
  ],
};
