chore(deploy): add PM2 ecosystem.config.cjs for listen mode
Single command `pm2 start ecosystem.config.cjs` avoids forgetting `-- listen`. Document npm script, README deploy path, and Proxmox post-create hints. Made-with: Cursor
This commit is contained in:
1 parent
6e70fbe1b3
commit
cd84efe0b8
4 files changed
+37
-2
No files matched your search
@@ -25,6 +25,7 @@ node src/index.js write "FC Porto match result"
|
||||
| `npm run write` | Write one article (manual mode) |
|
||||
| `npm run write -- "topic"` | Write article about specific topic |
|
||||
| `npm run listen` | Start auto RSS listener (cron) |
|
||||
| `npm run pm2:start` | PM2 via `ecosystem.config.cjs` (requires global `pm2`) |
|
||||
| `npm start` | Same as `write` |
|
||||
| `npm run dev` | Auto-restart with nodemon |
|
||||
|
||||
@@ -127,10 +128,13 @@ cd /srv/ai-news-writer
|
||||
npm install
|
||||
cp .env.example .env
|
||||
# edit .env: OPENAI_API_KEY, HOST=0.0.0.0, PORT=3200
|
||||
pm2 start src/index.js --name ai-news-writer --cwd /srv/ai-news-writer --time -- listen
|
||||
# pm2 delete ai-news-writer # only if replacing an old one-shot / wrong-args process
|
||||
pm2 start ecosystem.config.cjs
|
||||
pm2 save && pm2 startup
|
||||
```
|
||||
|
||||
*(Alternative, easier to mistype: `pm2 start src/index.js --name ai-news-writer --cwd /srv/ai-news-writer --time -- listen` — the `--` before `listen` is required.)*
|
||||
|
||||
**NPM (CT 102):** Proxy Host `ainews.bitreport.pt` → `http://<lxc-ip>:3200` (forward scheme **http** unless you terminate TLS only at NPM). Quick check from another machine: `curl -sS http://<lxc-ip>:3200/health` — JSON includes `version` and `mode: "listen"` so you can confirm the running build (and that this is not a one-shot `write` process).
|
||||
|
||||
**Typo check:** the hostname must be `ainews.bitreport.pt` (not `ainews.bitrepor.pt`).
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* PM2 process definition — always runs `listen` (HTTP + RSS cron).
|
||||
* Prefer this over `pm2 start src/index.js ... -- listen` to avoid footguns.
|
||||
*
|
||||
* Usage (inside CT, after clone + npm install + .env):
|
||||
* pm2 start ecosystem.config.cjs
|
||||
* pm2 save && pm2 startup
|
||||
*/
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'ai-news-writer',
|
||||
script: 'src/index.js',
|
||||
args: ['listen'],
|
||||
cwd: __dirname,
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: '512M',
|
||||
time: true,
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
HOST: '0.0.0.0',
|
||||
PORT: '3200',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -8,6 +8,7 @@
|
||||
"dev": "nodemon src/index.js",
|
||||
"write": "node src/index.js write",
|
||||
"listen": "node src/index.js listen",
|
||||
"pm2:start": "pm2 start ecosystem.config.cjs",
|
||||
"test": "node --test src/**/*.test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -57,7 +57,7 @@ echo "Next steps (per BIT-353):"
|
||||
echo " 1. Clone repo inside CT: git clone https://git.bitreport.pt/BitReport.pt/ai-news-writer.git /srv/ai-news-writer"
|
||||
echo " 2. Copy .env.example → /etc/ai-news-writer/ai-news-writer.env (fill secrets from vault)"
|
||||
echo " 3. cd /srv/ai-news-writer && cp .env.example .env && npm install"
|
||||
echo " pm2 start src/index.js --name ai-news-writer --cwd /srv/ai-news-writer --time -- listen"
|
||||
echo " pm2 start ecosystem.config.cjs"
|
||||
echo " 4. Register CTID/IP in vault; after board approval update docs/ENVIRONMENTS.md § LXCs"
|
||||
echo " 5. NPM CT 102: add Proxy Host ainews.bitreport.pt → http://<guest-ip>:3200"
|
||||
echo " User configures NPM manually (domain: ainews.bitreport.pt)"
|
||||
Reference in new issue
Block a user