railyard/apps/rithub-outage-protect/ecosystem.config.cjs
caelum0x 375995306e
Some checks failed
ci / cargo test (abacus) (push) Has been cancelled
ci / cargo test (agent-runtime) (push) Has been cancelled
ci / cargo test (context-passport) (push) Has been cancelled
ci / cargo test (game-economy) (push) Has been cancelled
ci / cargo test (ledgerline) (push) Has been cancelled
ci / cargo test (mint) (push) Has been cancelled
ci / cargo test (rago) (push) Has been cancelled
ci / cargo test (relay) (push) Has been cancelled
ci / cargo test (toolgate) (push) Has been cancelled
ci / cargo test (turnstile) (push) Has been cancelled
ci / cargo test (vend) (push) Has been cancelled
ci / node suites (push) Has been cancelled
feat(rithub): RIT-ACT GitHub outage protection (push-mirror back to GitHub)
One-click /protect page adds a real Gitea push-mirror from every
GitHub-imported repo back to its original GitHub location, so a push
to Rithub during a GitHub outage or account lockout syncs back once
GitHub recovers. Builds on the existing pull-mirror (GitHub -> Rithub,
already shipped) and Gitea's own push-mirror API -- GitHub has no
outbound mirror of its own. Jev-picked over two other candidates
(agent push approval, full account export), live-verified end to end
with a disposable mail.tm account and a real imported repo.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-30 23:19:06 +03:00

49 lines
1.7 KiB
JavaScript

// pm2 process definition for Rithub's GitHub-outage protection service
// (RIT-ACT). Bound to 127.0.0.1 only -- public exposure is via Caddy's
// /protect* handle block on rithub.dev (see
// /etc/caddy/sites-enabled/rithub-dev.caddy), same pattern already used
// for /billing*, /mcp*, /agent-tokens*.
const fs = require("node:fs");
// Minimal, dependency-free KEY=VALUE loader -- same /etc/products/*.env
// convention used by rithub-billing/rithub-mcp.
function loadEnvFile(path) {
try {
const out = {};
for (const line of fs.readFileSync(path, "utf8").split("\n")) {
const match = /^([A-Z0-9_]+)=(.*)$/.exec(line.trim());
if (match) out[match[1]] = match[2];
}
return out;
} catch {
return {}; // file not present (e.g. local dev) -- service stays unconfigured, /protect/health reports configured:false.
}
}
// Reuses the exact same Rithub admin token already minted for rithub-mcp
// (RITHUB_ADMIN_TOKEN) -- same reuse rithub-lifecycle.py already does,
// rather than minting a second admin credential for the same box.
const secrets = loadEnvFile("/etc/products/rithub-mcp.env");
module.exports = {
apps: [
{
name: "rithub-outage-protect",
cwd: __dirname,
script: "bin/start.mjs",
env: {
NODE_ENV: "production",
PORT: "3355",
RITHUB_BASE_URL: "https://rithub.dev",
RITHUB_API_BASE: "http://127.0.0.1:3350",
GITEA_DB_CONTAINER: "railyard-gitea-gitea-postgres-1",
RITHUB_OUTAGE_PROTECT_DATA_DIR: "/var/lib/rithub-outage-protect/",
RITHUB_ADMIN_TOKEN: secrets.RITHUB_ADMIN_TOKEN || "",
},
autorestart: true,
max_restarts: 10,
min_uptime: "10s",
},
],
};