Files
pyre/ecosystem.config.cjs
RogueWave 6ab0f02d06 feat(prometheus): real providers (Gemini/fal/Pollinations…) + secure key store
- Secure secrets: gitignored ~/pyre/.env (chmod 600) loaded into the API via
  `node --env-file-if-exists`; keys never committed/logged/returned. .env.example
  documents the vars. Free-first default (text=gemini, image=pollinations).
- @pyre/config: provider selection + key fields.
- @pyre/prometheus: real providers via fetch (no SDK deps) — Gemini/Anthropic/
  OpenAI text, Pollinations(free)/fal/DeepInfra/Replicate image, OpenAI moderation;
  `createProviders()` factory selects by config + key presence, falls back to stub.
  29 tests.
- @pyre/api: /api/prometheus/generate builds providers from config; keys never logged.

Live-verified end-to-end: admin-gated generate returned a real Spawn ("Ashen
Golem"/$AGOL) with a Pollinations image on the $0 stub-text+free-image stack;
.env-loaded admin token enforced. typecheck 8/8, 150 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 07:23:18 +00:00

87 lines
3.3 KiB
JavaScript

// 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`,
},
],
};