// PYRE / Prometheus Protocol — PM2 ecosystem (process manager) config. // // Process names match docs/PYRE_MVP_DESIGN.md §12: pyre-web, pyre-api, pyre-worker. // Start (from repo root): pm2 start ecosystem.config.cjs --only pyre-api,pyre-web // Persist for boot: pm2 save (systemd unit infra/systemd/pm2-pyre.service // runs `pm2 resurrect` on boot) // // PM2 is installed at user level: ~/.local/share/pnpm/bin/pm2 // Logs go to /home/pyre/pyre/logs/ (rotated by infra/logrotate/pyre). // Each process is capped at 400M (8GB VPS shared with postgres/redis/nginx). // // NOTE: api/worker run their TypeScript directly via `node --import tsx` (no // separate build step; tsx resolves the workspace `@pyre/*` source packages). // The web app runs Next.js in production mode and requires a prior `next build`. const REPO = __dirname; module.exports = { apps: [ { // Next.js frontend (production) — port 3000 per .env.example (WEB_PORT). // Requires `pnpm --filter @pyre/web build` first. name: "pyre-web", cwd: `${REPO}/apps/web`, script: "node_modules/next/dist/bin/next", args: "start", instances: 1, exec_mode: "fork", autorestart: true, max_memory_restart: "500M", env: { NODE_ENV: "production", PORT: 3000, HOSTNAME: "127.0.0.1", }, out_file: `${REPO}/logs/pyre-web-out.log`, error_file: `${REPO}/logs/pyre-web-err.log`, }, { // Fastify HTTP API — port 4000 per .env.example (API_PORT). // Runs TS directly via tsx (resolves workspace @pyre/* source). name: "pyre-api", cwd: `${REPO}/apps/api`, script: "src/index.ts", interpreter: "node", // Load secrets from the gitignored ~/pyre/.env (chmod 600) if present, // then register tsx. Keys never live in this committed file. interpreter_args: `--env-file-if-exists=${REPO}/.env --import tsx`, instances: 1, exec_mode: "fork", autorestart: true, max_memory_restart: "400M", env: { NODE_ENV: "production", PORT: 4000, HOST: "127.0.0.1", WEB_PUBLIC_URL: "https://feedthepyre.com", // Public RPC by default — override with a Helius/Triton/QuickNode URL // (set SOLANA_RPC_URL in the environment) to avoid mainnet rate limits. SOLANA_RPC_URL: "https://api.mainnet-beta.solana.com", }, out_file: `${REPO}/logs/pyre-api-out.log`, error_file: `${REPO}/logs/pyre-api-err.log`, }, { // BullMQ background worker (no HTTP port). Not started by default in // Phase 1 (no jobs implemented yet). Runs TS via tsx when enabled. name: "pyre-worker", cwd: `${REPO}/apps/worker`, script: "src/index.ts", interpreter: "node", // Load secrets from the gitignored ~/pyre/.env (chmod 600) if present, // then register tsx. Keys never live in this committed file. interpreter_args: `--env-file-if-exists=${REPO}/.env --import tsx`, instances: 1, exec_mode: "fork", autorestart: true, max_memory_restart: "400M", env: { NODE_ENV: "production", }, out_file: `${REPO}/logs/pyre-worker-out.log`, error_file: `${REPO}/logs/pyre-worker-err.log`, }, ], };