Repository Public
1/**2 * PM2 — the two processes of ATLAS IA on the production node. Not started by anything in this repository:3 * the deployment is performed by the lead (see docs/DEPLOYMENT.md).4 *5 * pm2 start ecosystem.config.cjs && pm2 save6 *7 * Environment comes from `.env` (and `.env.production`, if any) next to this file — see8 * `.env.production.example`; chmod 600. Both processes must see the same ATLAS_DATA_DIR.9 */10const { readFileSync, existsSync } = require("node:fs");11const { join } = require("node:path");1213// `.env` is the file the existing deployment already uses; `.env.production`, when present, is read after it and wins.14const env = { NODE_ENV: "production" };15for (const name of [".env", ".env.production"]) {16 const file = join(__dirname, name);17 if (existsSync(file)) for (const line of readFileSync(file, "utf8").split("\n")) { const m = /^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/.exec(line); if (m && !line.trim().startsWith("#")) env[m[1]] = m[2].replace(/^(["'])(.*)\1$/, "$2"); }18}1920module.exports = {21 apps: [22 {23 name: "atlas-web", cwd: __dirname, script: "node_modules/next/dist/bin/next", args: `start -p ${env.PORT || 8840} -H ${env.HOST || "0.0.0.0"}`,24 env, instances: 1, exec_mode: "fork", autorestart: true, max_memory_restart: "1G", kill_timeout: 10000, time: true,25 },26 {27 // The media worker: drains the job queue (ffmpeg). SIGTERM gives the job in progress back to the queue.28 name: "atlas-worker", cwd: __dirname, script: "node_modules/tsx/dist/cli.mjs", args: "scripts/worker.ts",29 env, instances: 1, exec_mode: "fork", autorestart: true, restart_delay: 5000, kill_timeout: 20000, time: true,30 },31 ],32};33