module.exports = { apps: [{ name: 'transcription-server', script: 'server.js', cwd: '/home/shadowdao/local-transcription/server/nodejs', // ← Update this path exec_mode: 'fork', instances: 1, autorestart: true, watch: false, max_memory_restart: '512M', // ← Increased (transcription data in memory) kill_timeout: 5000, // ← Give time for WebSocket cleanup wait_ready: false, listen_timeout: 5000, env: { NODE_ENV: 'development', PORT: 3000, DATA_DIR: '/home/shadowdao/local-transcription/server/nodejs/data', // ← Data directory NODE_OPTIONS: '--max-old-space-size=400' // ← Increased memory }, env_production: { NODE_ENV: 'production', PORT: 3000, DATA_DIR: '/home/shadowdao/local-transcription/server/nodejs/data', NODE_OPTIONS: '--max-old-space-size=400' }, log_file: '/home/shadowdao/logs/transcription/app.log', error_file: '/home/shadowdao/logs/transcription/error.log', out_file: '/home/shadowdao/logs/transcription/out.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', log_type: 'json', merge_logs: true, max_restarts: 10, // ← More retries (WebSocket can be finicky) min_uptime: '10s', // Graceful shutdown for WebSocket connections shutdown_with_message: true }] };