fable-agent/deploy/ecosystem.config.cjs

43 lines
989 B
JavaScript

// PM2 Ecosystem File — `pm2 start deploy/ecosystem.config.cjs`
// Manages the fable-agent daemon, auto-restarts, and log rotation.
module.exports = {
apps: [{
name: "fable-agent",
script: "dist/index.js",
args: "daemon start",
cwd: "/opt/fable-agent",
node_args: "--max-old-space-size=4096",
// Restart behavior
autorestart: true,
max_restarts: 10,
restart_delay: 30000,
exp_backoff_restart_delay: 100,
// Logging
out_file: "LOGS/pm2-out.log",
error_file: "LOGS/pm2-err.log",
log_date_format: "YYYY-MM-DD HH:mm:ss Z",
merge_logs: true,
// Max memory before restart
max_memory_restart: "4G",
// Environment
env: {
NODE_ENV: "production",
FABLE_DATA_DIR: "/var/lib/fable-agent",
},
env_file: "/etc/fable-agent.env",
// Graceful shutdown
kill_timeout: 10000,
listen_timeout: 5000,
// Watch for config changes
watch: ["CONFIG.md"],
watch_delay: 10000,
}],
};