require('dotenv').config(); const DEPLOY_PATH = process.env.SREBOT_DEPLOY_PATH || __dirname; module.exports = { apps: [ // Discord Bot { name: 'srebot', script: 'start_bot.py', interpreter: `${DEPLOY_PATH}/.venv/bin/python`, cwd: DEPLOY_PATH, instances: 1, autorestart: true, watch: false, max_memory_restart: '16000M', env: { NODE_ENV: 'production', PYTHONUNBUFFERED: '1' }, log_file: './logs/bot_combined.log', out_file: './logs/bot_out.log', error_file: './logs/bot_error.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', merge_logs: true, kill_timeout: 5000, restart_delay: 3000 }, // API Server { name: 'srebot-api', script: 'server.js', interpreter: 'node', node_args: '--max-old-space-size=6144', cwd: DEPLOY_PATH, instances: 1, autorestart: true, watch: false, max_memory_restart: '4G', env: { NODE_ENV: 'production', PORT: 6000 }, log_file: './logs/api_combined.log', out_file: './logs/api_out.log', error_file: './logs/api_error.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', merge_logs: true, kill_timeout: 5000, restart_delay: 2000 }, // External bridge for AXBot traffic: // - Proxies read-only API queries to the internal SREBOT API // - Streams bridge envelopes to AXBot over websocket { name: 'srebot-axbot', script: 'BOT/srebot_external.py', interpreter: `${DEPLOY_PATH}/.venv/bin/python`, cwd: DEPLOY_PATH, instances: 1, autorestart: true, watch: false, max_memory_restart: '1G', env: { NODE_ENV: 'production', PYTHONUNBUFFERED: '1', SREBOT_EXTERNAL_HOST: '0.0.0.0', SREBOT_EXTERNAL_PORT: 18081, SREBOT_EXTERNAL_UPSTREAM_URL: 'http://127.0.0.1:6000' }, log_file: './logs/axbot_combined.log', out_file: './logs/axbot_out.log', error_file: './logs/axbot_error.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', merge_logs: true, kill_timeout: 5000, restart_delay: 2000 }, // GitHub Webhook Receiver (auto-deploy on push to main) { name: 'srebot-webhook', script: 'github_webhook_updater.py', interpreter: `${DEPLOY_PATH}/.venv/bin/python`, cwd: DEPLOY_PATH, instances: 1, autorestart: true, watch: false, max_memory_restart: '500M', env: { NODE_ENV: 'production', PYTHONUNBUFFERED: '1', WEBHOOK_PORT: 9000 }, log_file: './logs/webhook_combined.log', out_file: './logs/webhook_out.log', error_file: './logs/webhook_error.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', merge_logs: true, kill_timeout: 3000, restart_delay: 2000 }, // Website (Next.js) { name: 'srebot-web', script: 'server.js', cwd: `${DEPLOY_PATH}/web`, instances: 3, exec_mode: 'cluster', autorestart: true, watch: false, max_memory_restart: '500M', env: { NODE_ENV: 'production', PORT: 3001 }, log_file: './logs/web_combined.log', out_file: './logs/web_out.log', error_file: './logs/web_error.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', merge_logs: true, kill_timeout: 5000 } ] };