// PM2 process definition for the OCI Compute deployment (see docs/OCI_COMPUTE_SETUP.md).
// Single fork instance ON PURPOSE: TuneVault runs an in-process scheduler (cron sweeps,
// AutoPilot heartbeat, agent poll loop). Cluster mode / instances>1 double-fires them.
module.exports = {
  apps: [{
    name: 'tunevault',
    script: 'server.js',
    cwd: '/opt/tunevault',
    instances: 1,            // MUST stay 1 — single scheduler / agent poll loop
    exec_mode: 'fork',
    max_memory_restart: '900M',
    env_production: { NODE_ENV: 'production' },
    error_file: '/home/opc/.pm2/logs/tunevault-error.log',
    out_file:   '/home/opc/.pm2/logs/tunevault-out.log',
    time: true,
  }],
};
