{"success":true,"name":"brimind-pay-vps-split","description":"pay.brimind.pro runs its own separate pay-invoicer on the [PRIVATE_HOST], not on this laptop — how to tell, how to hand a client a link that actually works while the two are unmerged, and what \"deploy\" means when the owner is ready. Fires whenever a link on pay.brimind.pro 404s that works on [PRIVATE_HOST], before minting or sending any /offre, /choix, /i or /pay link, and whenever someone says \"i","category":"unitary","path":"unitary/brimind-pay-vps-split/SKILL.md","file":"SKILL.md","content":"---\nname: brimind-pay-vps-split\ndescription: pay.brimind.pro runs its own separate pay-invoicer on the [PRIVATE_HOST], not on this laptop — how to tell, how to hand a client a link that actually works while the two are unmerged, and what \"deploy\" means when the owner is ready. Fires whenever a link on pay.brimind.pro 404s that works on [PRIVATE_HOST], before minting or sending any /offre, /choix, /i or /pay link, and whenever someone says \"it's not live\" about a devis or invoice.\n---\n> Imported from [PRIVATE_HOST] `~/unitary/agents/skills/brimind-pay-vps-split`. Paths are relative to `[PRIVATE_HOST]:[PATH]`; run commands there via `ssh [PRIVATE_HOST] 'cd ~/unitary && ...'`. Owner send rules from skill i7-remote-ops still apply.\n\n\n> **2026-09-04 update — see [`brimind-send-pay-brimind-not-offer`](../brimind-send-pay-brimind-not-offer/SKILL.md).**\n> The owner has since ruled that no client-facing link may ever be\n> `pay.offer.brimind.pro` (tunnel, intermittent) — only `pay.brimind.pro`\n> ([PRIVATE_HOST], 24/7). If the [PRIVATE_HOST] build is stale or wrong, that is a bug to fix, not\n> a reason to send the tunnel address. The verification technique below still\n> applies; the \"hand the client `pay.offer.brimind.pro`\" fallback does not.\n\n# pay.brimind.pro is not this laptop (found 2026-09-03)\n\nEvery older note — including `brimind-pay-offers`'s \"one app, one database\" —\nsays `pay.brimind.pro` is nothing but a tunnel down to this laptop's\n`[PRIVATE_HOST]`. **That stopped being true, and may never have been true.**\nOn 2026-09-03 the public domain was traced to a **separate `pay-invoicer`\nrunning directly on the [PRIVATE_HOST]** ([PRIVATE_HOST]) under its own `systemctl`\nservice, with its own build. Confirmed two ways:\n\n```bash\ncurl -s https://pay.brimind.pro/  | grep -o 'main-app-[a-z0-9]*\\.js' | head -1\ncurl -s http://[PRIVATE_HOST]/    | grep -o 'main-app-[a-z0-9]*\\.js' | head -1\n```\n\n**Different chunk name → different process, full stop.** Do this check before\ntrusting any pay.brimind.pro link, not just the first time something breaks —\nthe two builds can drift apart again at any point without warning.\n\nShell access exists: `ssh [PRIVATE_HOST]` (user `adminops`, passwordless\n`sudo -n`). Topology drifts — re-check it, don't trust the last note:\n\n```bash\nssh [PRIVATE_HOST] 'grep -A3 \"pay.brimind.pro\" /etc/caddy/Caddyfile'   # which port Caddy forwards to\nssh [PRIVATE_HOST] 'sudo -n ss -tlnp | grep <that port>'               # who owns it\n```\n\nAs last re-checked, Caddy forwards `pay.brimind.pro` -> `[PRIVATE_HOST]`, and\nthat port is held by **`sshd`**, not a local `next-server` — i.e. the real\n`pay-invoicer` backend is reached through a **reverse SSH tunnel** from some\nother host, and there is **no `pay-invoicer` systemd unit on the [PRIVATE_HOST]**\n(`systemctl list-units | grep -i pay` and `journalctl -u pay-invoicer` both\ncame back empty). This contradicts the \"separate [PRIVATE_HOST] build with its own\nsystemctl service\" story below — treat that story as stale until re-verified\nwith the commands above, not as fact. (`tunnel@` is sftp-only and `root@` has\nno key — use `adminops`.)\n\nWhen the live site shows a payment/API error (e.g. ClicToPay \"paiement n'a pas\npu être démarré\"), that almost always means the tunnel's far end — the actual\n`pay-invoicer` process — is down or unreachable, not a [PRIVATE_HOST] code bug. Hunt for\nit before assuming a [PRIVATE_HOST] deploy issue: check `pm2 list` / `pm2 describe\npay-invoicer` on [PRIVATE_HOST] (`ssh [PRIVATE_HOST] 'bash -lic \"pm2 list\"'` — plain `ssh [PRIVATE_HOST] pm2` finds\nnothing, PATH needs the login shell) and on the Mac (`pm2 list`, `lsof\n-iTCP:3010 -sTCP:LISTEN`). If none of those show it, say so plainly to the\nuser instead of guessing a fix — the right host may not be one you have\naccess to yet.\n\n## 502 on pay.brimind.pro = nothing on [PRIVATE_HOST]:3010 (seen 2026-11-06)\n\n[PRIVATE_HOST] Caddy -> [PRIVATE_HOST] [PRIVATE_HOST] (sshd reverse tunnel) -> **[PRIVATE_HOST] [PRIVATE_HOST]**. When [PRIVATE_HOST]:3010 is empty the cause was the dashboard OOM loop: `brimind-dashboard.service` (systemd-oomd kills the whole cgroup) starts pay-invoicer as `npm run build && exec npm start` whenever `.next/prerender-manifest.json` is missing, several builds race in the same `.next`, oomd kills them, `.next` is left half-built, repeat. Fix that worked:\n1. Kill every `next build` whose `/proc/<pid>/cwd` is `pay-invoicer` (script file, not `pkill -f` in the ssh string).\n2. Build once in its own unit: `systemd-run --user -p ManagedOOMPreference=avoid bash script` with `NEXT_DIST_DIR=.next-hermes npm run build` (next.config reads it), then `mv .next .next-old && mv .next-hermes .next`.\n3. Serve outside the dashboard cgroup: `systemd-run --user --unit=brimind-pay-invoicer -p Restart=always --working-directory=~/unitary/pay-invoicer bash -lc 'exec npm start'`. The dashboard adopts a port that already answers HTTP, so no conflict. Transient unit: gone after reboot (dashboard takes over again).\nScript: `[PATH]`. [PRIVATE_HOST] build takes ~7 min at load 50.\n\n## The data layer is fixed; the [PRIVATE_HOST] build is not\n\nAs of 2026-09-03, invoices, site offers, custom payments, counters, settings,\nreferrals and affiliate reports all live in the shared MongoDB Atlas cluster\n(`brimind` db — the same one `references` already used), not in a per-machine\nJSON file. Anything minted through `[PRIVATE_HOST]` is instantly visible to\n**any other process pointed at the same `MONGODB_URI`** — laptop or [PRIVATE_HOST].\n\nThat means the split is now **only** a code/deploy problem, not a data\nproblem: once the [PRIVATE_HOST]'s `pay-invoicer` runs this same code against the same\n`MONGODB_URI`, `pay.brimind.pro` and this laptop become the same records\nagain, permanently. Until then, the [PRIVATE_HOST]'s own build still reads/writes\nwhatever store its own code points at — do not assume it sees what you just\nminted.\n\n## What to hand a client right now: use the tunnel, not pay.brimind.pro\n\n`brimind-tunnel/wildcard/config/tenants.config.json` already has a tenant that\nexposes this laptop's pay-invoicer over the working tunnel, no [PRIVATE_HOST] root\nneeded:\n\n```json\n{ \"slug\": \"pay\", \"mode\": \"tunnel\", \"forward\": \"pay-invoicer\", \"active\": true }\n```\n\nThat makes **`https://pay.offer.brimind.pro`** serve exactly what\n`[PRIVATE_HOST]` serves, live, through the reverse SSH tunnel that is already\nup. So while the [PRIVATE_HOST] build is stale:\n\n- Mint the offer/invoice/brochure locally as always (`dealflow invoice` +\n  `brochure`, or `npm run offer`).\n- The link printed will say `pay.brimind.pro` (from `SITE_URL` in `.env`) —\n  **swap the host for `pay.offer.brimind.pro`, keep the path**, e.g.\n  `https://pay.brimind.pro/offre/<id>` → `https://pay.offer.brimind.pro/offre/<id>`.\n- Prove it before sending: `curl -s -o /dev/null -w '%{http_code}' https://pay.offer.brimind.pro/offre/<id>`\n  must be 200, and its chunk hash must match `[PRIVATE_HOST]`'s (same check as\n  above, with `pay.offer.brimind.pro` on the left).\n\nThis is a stand-in, not the fix — it exists so a client is never handed a dead\nlink while the real merge is pending.\n\n## The deploy that syncs the [PRIVATE_HOST] build\n\nOnce `pay.offer.brimind.pro` has been checked working end to end, pointing\n`pay.brimind.pro` at the same code is a **single deploy** — the [PRIVATE_HOST]'s\n`pay-invoicer` needs this repo's current code (this `lib/store.js`, in\nparticular) and the same `MONGODB_URI`, then a restart:\n\n```bash\n# on the [PRIVATE_HOST] (ssh [PRIVATE_HOST], sudo -n), inside the pay-invoicer checkout\ngit pull\nnpm install\nnpm run build\nsystemctl restart pay-invoicer\n```\n\nIt touches a live payment site, so run it only on the owner's order, with a\nbackup of the current build and a before/after check of `pay.brimind.pro`.\n\n**After the deploy**, re-run the chunk-hash check. Matching hashes on\n`pay.brimind.pro` and `[PRIVATE_HOST]` is what \"merged again\" looks like —\nonly then does `pay.brimind.pro` go back to being the link you hand a client\nwithout the `pay.offer.brimind.pro` swap.\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}