cms.c2sgmbh/ecosystem.config.cjs
Martin Porwoll e904f0949b fix(queue): resolve queue-worker crash-loop via Redis auth and PM2 config
Redis requires authentication but IORedis connections were not passing a
password, causing immediate NOAUTH failures and a PM2 crash-loop (1900+
restarts). Additionally, the PM2 config used `npx` as the script entry
which caused instability.

- Add REDIS_PASSWORD support to queue-service.ts and redis.ts
- Change PM2 script from npx wrapper to direct tsx CLI entry point
- Add explicit exec_mode: 'fork' to prevent cluster mode issues

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:46:54 +00:00

58 lines
1.7 KiB
JavaScript

module.exports = {
apps: [
// Main Payload CMS App
{
name: 'payload',
cwd: '/home/payload/payload-cms',
script: 'pnpm',
args: 'start',
env: {
NODE_ENV: 'production',
PORT: 3000
},
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
error_file: '/home/payload/logs/error.log',
out_file: '/home/payload/logs/out.log',
time: true,
max_restarts: 10,
min_uptime: '10s',
restart_delay: 5000
},
// Queue Worker (BullMQ - Email + PDF)
{
name: 'queue-worker',
cwd: '/home/payload/payload-cms',
script: 'node_modules/tsx/dist/cli.mjs',
args: 'scripts/run-queue-worker.ts',
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
// Credentials werden via dotenv aus .env geladen (siehe run-queue-worker.ts)
// Queue-spezifische Env Vars
QUEUE_EMAIL_CONCURRENCY: '3',
QUEUE_PDF_CONCURRENCY: '2',
QUEUE_DEFAULT_RETRY: '3',
QUEUE_REDIS_DB: '1',
// Worker aktivieren/deaktivieren
QUEUE_ENABLE_EMAIL: 'true',
QUEUE_ENABLE_PDF: 'true',
// PDF-spezifische Optionen
PDF_OUTPUT_DIR: '/tmp/payload-pdfs',
// PDF_GENERATION_DISABLED: 'true', // Für Tests
},
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '768M', // PDF-Generierung braucht mehr RAM
error_file: '/home/payload/logs/queue-worker-error.log',
out_file: '/home/payload/logs/queue-worker-out.log',
time: true,
max_restarts: 10,
min_uptime: '5s',
restart_delay: 3000,
}
]
}