feat(ecosystem): update PM2 configuration for control plane and web server
Deploy to Raspberry Pi / deploy (push) Successful in 52s

- Renamed the control process to `jflow-control` and updated the script path to `control.js`.
- Introduced a new `jflow-web` process for the production UI, serving on port 8500.
- Enhanced environment variable handling for both processes, ensuring proper port assignments.
- Updated README to reflect new process architecture and usage instructions for starting the application.
This commit is contained in:
2026-08-22 22:32:04 +07:00
parent 0a8463d8f4
commit be8122f9e5
6 changed files with 270 additions and 16 deletions
+29 -8
View File
@@ -1,7 +1,9 @@
/**
* Production PM2 ecosystem (monolith runner).
* Use for deployed/single-process starts. For local multi-process Ops UI, use
* `pnpm dev:pm2` → packages/server/ecosystem.dev.cjs / control.js instead.
* Production PM2 ecosystem (control plane + UI).
* Starts always-on processes only; HTTP (:8700) and workers are owned by
* control.js via PM2 (same as `pnpm dev:pm2`).
*
* Prerequisites: `pnpm build` (packages/web/dist), Redis, .env secrets.
*/
const fs = require("fs");
const path = require("path");
@@ -28,21 +30,40 @@ function loadEnv(file) {
}
const root = __dirname;
const env = {
NODE_ENV: "production",
...loadEnv(path.join(root, ".env")),
};
module.exports = {
apps: [
{
name: "jerapah-flow",
name: "jflow-control",
cwd: root,
script: "packages/server/runner.js",
script: "packages/server/control.js",
interpreter: "node",
instances: 1,
autorestart: true,
max_restarts: 20,
env: {
NODE_ENV: "production",
...loadEnv(path.join(root, ".env")),
...env,
JFLOW_CONTROL_PORT: env.JFLOW_CONTROL_PORT ?? "8600",
},
},
{
name: "jflow-web",
cwd: root,
script: "packages/server/web-server.js",
interpreter: "node",
instances: 1,
autorestart: true,
max_restarts: 20,
env: {
...env,
JFLOW_UI_PORT: env.JFLOW_UI_PORT ?? "8500",
JFLOW_CONTROL_PORT: env.JFLOW_CONTROL_PORT ?? "8600",
JFLOW_HTTP_PORT: env.JFLOW_HTTP_PORT ?? "8700",
},
},
],
};
};