The v* tag deploy previously only updated the Next app (ppms); GstService / EpfoService / PdfService were never built or restarted by automation. Now the same deploy manages them. - ecosystem.config.js (root): pm2 definitions for gst-service (3003) / epfo-service (3004) / pdf-service (3005). Registers only services whose source is checked out (keyed on package.json), so a not-yet-merged service is skipped and adopted automatically once its PR lands. Secrets come from the env at pm2 invocation; ports are fixed here. - deploy.yml: after the app restart, export the few service secrets out of App/.env (never PORT or the ephemeral FORGEJO_TOKEN), npm install + playwright install chromium + build each present service, then `pm2 startOrReload ecosystem.config.js --update-env` (create on first release, reload after) + pm2 save, and health-check :3003/:3004/:3005. - automation/README.md: documents the flow + the one-time alignment for any pre-existing differently-named pm2 process. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.9 KiB
JavaScript
43 lines
1.9 KiB
JavaScript
// pm2 process definitions for the Pelagia microservices.
|
|
//
|
|
// The Next app (pm2 `ppms`) is deployed/restarted separately by
|
|
// .forgejo/workflows/deploy.yml — deliberately, so its delicate env handling
|
|
// (avoiding the runner's ephemeral FORGEJO_TOKEN) is untouched. This file covers
|
|
// only the standalone Playwright services. The deploy builds each, then runs
|
|
// pm2 startOrReload ecosystem.config.js --update-env
|
|
// which CREATES them on first release and RELOADS them on subsequent ones.
|
|
//
|
|
// Resilient to services that aren't in the tree yet (e.g. PdfService lands with
|
|
// its feature PR): only directories that exist are registered. Ports are fixed
|
|
// here (matching the app's *_SERVICE_URL defaults). Secrets are read from the
|
|
// deploy environment at `pm2` invocation time — the deploy exports the few keys
|
|
// these services need out of App/.env first (never PORT or FORGEJO_*). Unset →
|
|
// harmless defaults (GST/EPFO stay stub-capable, PdfService skips token/origin checks).
|
|
const path = require("path");
|
|
const fs = require("fs");
|
|
const root = __dirname;
|
|
|
|
const DEFS = [
|
|
{ name: "gst-service", dir: "GstService", env: { PORT: "3003" } },
|
|
{ name: "epfo-service", dir: "EpfoService", env: { PORT: "3004", EPFO_LIVE: process.env.EPFO_LIVE || "" } },
|
|
{
|
|
name: "pdf-service",
|
|
dir: "PdfService",
|
|
env: {
|
|
PORT: "3005",
|
|
PDF_SERVICE_TOKEN: process.env.PDF_SERVICE_TOKEN || "",
|
|
ALLOWED_ORIGIN: process.env.ALLOWED_ORIGIN || "",
|
|
},
|
|
},
|
|
];
|
|
|
|
module.exports = {
|
|
// Key on package.json — present only when the service source is checked out
|
|
// (a lingering gitignored node_modules/ dir must not register a phantom app).
|
|
apps: DEFS.filter((d) => fs.existsSync(path.join(root, d.dir, "package.json"))).map((d) => ({
|
|
name: d.name,
|
|
cwd: path.join(root, d.dir),
|
|
script: "dist/index.js",
|
|
env: { NODE_ENV: "production", ...d.env },
|
|
})),
|
|
};
|