Files
SREBOT/ecosystem.config.js
T
NotSoToothless ec08655a59 drop require('dotenv') from ecosystem.config.js files (#1230)
TSSBOT has no node_modules/ on the server (no package.json was ever
installed for it), so `require('dotenv').config()` crashes pm2 with
MODULE_NOT_FOUND when it loads the ecosystem file. The dotenv call was
already dead code: every spawned app loads its own .env in its own
process (botscript.py, server.js, web/server.js, webhook updater,
TSSBOT/start_bot.py all do load_dotenv / require('dotenv').config()
themselves). Remove the require from both ecosystem files.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:09:51 -07:00

111 lines
3.3 KiB
JavaScript

// Single source of truth for runtime config is SREBOT/.env. Each spawned
// process loads it independently (botscript.py via python-dotenv, server.js
// and web/server.js via `require('dotenv').config()`, github_webhook_updater.py
// via python-dotenv). Do NOT add `env:` blocks below or load dotenv here —
// either would create a second config source that can silently shadow .env.
const 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',
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 (reads SREBOT_API_PORT from .env)
{
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',
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
// Reads SREBOT_EXTERNAL_HOST/PORT/UPSTREAM_URL from .env.
{
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',
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).
// Reads SREBOT_WEBHOOK_PORT from .env.
{
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',
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 (reads SREBOT_WEB_PORT from .env)
{
name: 'srebot-web',
script: 'server.js',
cwd: `${DEPLOY_PATH}/web`,
instances: 3,
exec_mode: 'cluster',
autorestart: true,
watch: false,
max_memory_restart: '500M',
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
}
]
};