const path = require('path');

const cwd = __dirname;
const script = path.join(cwd, 'scripts', 'start-besu-node.js');

module.exports = {
  apps: [
    { name: 'plais-qbft-validator-1', script, args: 'validator-1', cwd },
    { name: 'plais-qbft-validator-2', script, args: 'validator-2', cwd },
    { name: 'plais-qbft-validator-3', script, args: 'validator-3', cwd },
    { name: 'plais-qbft-validator-4', script, args: 'validator-4', cwd },
    { name: 'plais-qbft-rpc', script, args: 'rpc', cwd },
    {
      name: 'plais-qbft-public-bridge',
      script: path.join(cwd, 'scripts', 'start-qbft-public-bridge.js'),
      cwd
    },
    {
      name: 'plais-point-conversion-worker',
      script: path.join(cwd, 'scripts', 'process-canonical-point-conversions.js'),
      args: ['--watch', '--confirm=SIGN_CANONICAL_POINT_CONVERSIONS'],
      cwd
    }
  ].map((app) => ({
    ...app,
    autorestart: true,
    max_restarts: 10,
    min_uptime: '10s',
    kill_timeout: 15000,
    time: true
  }))
};
