Files
crypto_monitor/manual_trading_hub/scripts/run_agent.sh
T

25 lines
665 B
Bash
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.
#!/usr/bin/env bash
# PM2 子代理入口:在策略目录(cwd)加载 .env 后启动 agent.py
# EXCHANGE / PORT / HOST 由 ecosystem.config.cjs 注入,.env 里一般无 PORT,不会覆盖
set -euo pipefail
HUB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENV_PY="${HUB_DIR}/.venv/bin/python"
AGENT_PY="${HUB_DIR}/agent.py"
if [[ ! -x "${VENV_PY}" ]]; then
echo "未找到 ${VENV_PY},请先在 manual_trading_hub 下创建 venv" >&2
exit 1
fi
if [[ -f .env ]]; then
set -a
# shellcheck disable=SC1091
. ./.env
set +a
else
echo "警告: $(pwd) 下无 .envagent 可能缺少 API 密钥" >&2
fi
exec "${VENV_PY}" "${AGENT_PY}"