const path = require("path");

const root = __dirname;

/** @type {import('pm2').StartOptions[]} */
const apps = [
  {
    name: "haixun-web",
    script: path.join(root, "scripts/pm2-web.sh"),
    interpreter: "bash",
    cwd: root,
    instances: 1,
    exec_mode: "fork",
    autorestart: true,
    max_restarts: 10,
    min_uptime: "10s",
    env: {
      NODE_ENV: "production",
      PORT: 3000,
    },
  },
  {
    name: "haixun-worker",
    script: path.join(root, "scripts/pm2-worker.sh"),
    interpreter: "bash",
    cwd: root,
    instances: 1,
    exec_mode: "fork",
    autorestart: true,
    max_restarts: 10,
    min_uptime: "10s",
    env: {
      NODE_ENV: "production",
    },
  },
  {
    name: "haixun-web-dev",
    script: path.join(root, "scripts/pm2-web-dev.sh"),
    interpreter: "bash",
    cwd: root,
    instances: 1,
    exec_mode: "fork",
    autorestart: true,
    max_restarts: 10,
    min_uptime: "10s",
    env: {
      NODE_ENV: "development",
      PORT: 3000,
    },
  },
];

module.exports = { apps };