rebreak-monorepo/ecosystem.config.js
chahinebrini a24a9c783f feat(mail): IDLE-daemon for real-time Legend mail-protection
Standalone ESM-daemon that:
- Connects via ImapFlow IDLE to all active Legend mailboxes
- Triggers /api/mail/scan-internal on new-mail events (real-time)
- Auto-renew IDLE every 25min (RFC 3501 limit), exponential-backoff reconnect
- DB-refresh every 5min for new/removed connections

Plus deploy-pipeline:
- GH-Actions artifact-upload + scp to /srv/rebreak/backend/imap-idle/
- npm install --production on server (imapflow + pg)
- pm2 startOrReload via ecosystem.config.js
- start-idle-staging.sh wrapper for Infisical secret-injection

Replaces 30min-cron polling for Legend tier -- Casino-mails now blocked
within seconds, fulfilling Legend tier marketing promise.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 20:48:33 +02:00

128 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* ecosystem.config.js PM2 Prozess-Konfiguration für Rebreak
* (backend/-Layout, post-cutover)
*
* Repo-Root: /srv/rebreak
* Backend: /srv/rebreak/backend (standalone Nitro)
* Node: /root/.nvm/versions/node/v24.11.1/bin/node
*
* Aktivierung auf Server:
* pm2 startOrReload /srv/rebreak/ecosystem.config.js
*/
const NODE_BIN = "/root/.nvm/versions/node/v24.11.1/bin/node";
const REPO_ROOT = "/srv/rebreak";
const APP_DIR = `${REPO_ROOT}/backend`;
module.exports = {
apps: [
// ─── Rebreak Staging (Nitro standalone) ────────────────────────────────
{
name: "rebreak-staging",
script: `${APP_DIR}/start-staging.sh`,
interpreter: "bash",
cwd: APP_DIR,
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "700M",
env: {
NODE_ENV: "production",
PORT: "3016",
NITRO_PORT: "3016",
},
},
// ─── Rebreak Prod (Nitro standalone) ───────────────────────────────────
// Wird erst aktiviert wenn Phase 3 (DNS-Cutover) abgeschlossen ist.
// start-prod.sh wird analog start-staging.sh aufgesetzt
// (existiert noch nicht im backend/ — nicht-blockierend für Cutover).
// Start: pm2 start ecosystem.config.js --only rebreak
// {
// name: "rebreak",
// script: `${APP_DIR}/start-prod.sh`,
// interpreter: "bash",
// cwd: APP_DIR,
// instances: 1,
// autorestart: true,
// watch: false,
// max_memory_restart: "700M",
// env: {
// NODE_ENV: "production",
// PORT: "3015",
// NITRO_PORT: "3015",
// },
// },
// ─── Admin Staging (Nuxt 4 SSR, port 3017) ────────────────────────────
// Wird einmalig via SSH initial gestartet (pm2 start ecosystem.config.js --only rebreak-admin-staging).
// Danach: deploy-admin-from-artifact.sh uebernimmt Restarts.
// start-admin-staging.sh: infisical run + node .output-staging/server/index.mjs
{
name: "rebreak-admin-staging",
script: `${REPO_ROOT}/apps/admin/start-admin-staging.sh`,
interpreter: "bash",
cwd: `${REPO_ROOT}/apps/admin`,
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "400M",
env: {
NODE_ENV: "production",
PORT: "3017",
NITRO_PORT: "3017",
},
},
// ─── Webhook-Listener ──────────────────────────────────────────────────
{
name: "rebreak-webhook",
script: `${REPO_ROOT}/scripts/deploy-webhook/server.mjs`,
interpreter: NODE_BIN,
cwd: REPO_ROOT,
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "128M",
},
// ─── IMAP IDLE Daemon Staging ───────────────────────────────────────────
// Deployment-Anleitung: docs/internal/MAIL_DAEMON_DEPLOYMENT.md
// start-idle-staging.sh injiziert Infisical-Secrets (DATABASE_URL, ADMIN_SECRET, ENCRYPTION_KEY).
// Initialer Start via: pm2 startOrReload /srv/rebreak/ecosystem.config.js
{
name: "rebreak-idle-staging",
script: `${APP_DIR}/imap-idle/start-idle-staging.sh`,
interpreter: "bash",
cwd: `${APP_DIR}/imap-idle`,
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "256M",
env: { NODE_ENV: "production" },
},
// ─── DNS-Blocker (auskommentiert bis DNS-Daemons aufgesetzt sind) ──────
// {
// name: "dns-rebreak",
// script: `${APP_DIR}/server/dns/start-prod.sh`,
// interpreter: "bash",
// cwd: `${APP_DIR}/server/dns`,
// instances: 1,
// autorestart: true,
// watch: false,
// max_memory_restart: "512M",
// },
// {
// name: "dns-rebreak-staging",
// script: `${APP_DIR}/server/dns/start-staging.sh`,
// interpreter: "bash",
// cwd: `${APP_DIR}/server/dns`,
// instances: 1,
// autorestart: true,
// watch: false,
// max_memory_restart: "512M",
// },
],
};