Files
crypto_monitor/manual_trading_hub/ecosystem.config.cjs
T

62 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* PM2:中控 hub + 四路子代理 agent(一次启动全部)
*
* 前置:
* cd manual_trading_hub
* source .venv/bin/activate && pip install -r requirements.txt
* cp .env.example .env
*
* 启动(hub + 全部 agent):
* pm2 start ecosystem.config.cjs
* pm2 save && pm2 startup
*
* 仅中控:pm2 start ecosystem.config.cjs --only manual-trading-hub
* 仅某 agentpm2 start ecosystem.config.cjs --only manual-agent-binance
*
* 快捷:bash scripts/pm2_hub.sh start
*/
const path = require("path");
const HUB_DIR = __dirname;
const REPO_ROOT = path.join(HUB_DIR, "..");
const PY = path.join(HUB_DIR, ".venv", "bin", "python");
const AGENT = path.join(HUB_DIR, "agent.py");
const RUN_SH = path.join(HUB_DIR, "scripts", "run_hub.sh");
function agentApp(name, exchangeDir, exchange, port) {
return {
name,
cwd: path.join(REPO_ROOT, exchangeDir),
script: AGENT,
interpreter: PY,
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "400M",
env: {
EXCHANGE: exchange,
PORT: String(port),
HOST: "127.0.0.1",
},
};
}
module.exports = {
apps: [
agentApp("manual-agent-binance", "crypto_monitor_binance", "binance", 15200),
agentApp("manual-agent-okx", "crypto_monitor_okx", "okx", 15201),
agentApp("manual-agent-gate", "crypto_monitor_gate", "gate", 15202),
agentApp("manual-agent-gate-bot", "crypto_monitor_gate_bot", "gate", 15203),
{
name: "manual-trading-hub",
cwd: HUB_DIR,
script: RUN_SH,
interpreter: "bash",
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "512M",
},
],
};