Add single-exchange instance-only deploy menu options.

Manage menu 4/5/6 install OKX/Binance/Gate Flask only without hub or agents; reuse setup_env --only and narrowed PM2 verify.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 15:40:25 +08:00
parent 2269bc51ff
commit 0f12e0a8ea
6 changed files with 300 additions and 44 deletions
+123 -24
View File
@@ -330,9 +330,57 @@ pm2_count_online() {
is_deployed() {
local root="$1"
[[ -x "${root}/crypto_monitor_binance/.venv/bin/python" ]] \
|| [[ -x "${root}/crypto_monitor_gate/.venv/bin/python" ]] \
|| [[ -x "${root}/crypto_monitor_okx/.venv/bin/python" ]] \
|| [[ -x "${root}/manual_trading_hub/.venv/bin/python" ]]
}
# 单所实例: key -> 目录 / PM2 名 / 端口 / 展示名
exchange_dir() {
case "$1" in
okx) echo "crypto_monitor_okx" ;;
binance) echo "crypto_monitor_binance" ;;
gate) echo "crypto_monitor_gate" ;;
*) return 1 ;;
esac
}
exchange_pm2_name() {
case "$1" in
okx) echo "crypto_okx" ;;
binance) echo "crypto_binance" ;;
gate) echo "crypto_gate" ;;
*) return 1 ;;
esac
}
exchange_http_port() {
case "$1" in
okx) echo "5004" ;;
binance) echo "5001" ;;
gate) echo "5000" ;;
*) return 1 ;;
esac
}
exchange_label() {
case "$1" in
okx) echo "OKX" ;;
binance) echo "Binance" ;;
gate) echo "Gate" ;;
*) echo "$1" ;;
esac
}
normalize_exchange_key() {
local k
k="$(echo "${1:-}" | tr '[:upper:]' '[:lower:]' | xargs)"
case "${k}" in
okx|binance|gate) echo "${k}" ;;
*) return 1 ;;
esac
}
check_http() {
local url="$1"
local code
@@ -342,37 +390,62 @@ check_http() {
verify_deployment() {
local ip="${1:-$(detect_server_ip)}"
local mode="${2:-all}"
local ok=1
local online total
local ex_key=""
step "部署验收"
total="${#PM2_APPS[@]}"
online="$(pm2_count_online)"
if [[ "${online}" -eq "${total}" ]]; then
echo " [✓] PM2 进程 ${online}/${total} online"
else
echo " [✗] PM2 进程 ${online}/${total} online"
ok=0
pm2 list 2>/dev/null || true
fi
local checks=(
"中控:http://127.0.0.1:5100/"
"Binance:http://127.0.0.1:5001/"
"Gate:http://127.0.0.1:5000/"
"OKX:http://127.0.0.1:5004/"
)
local item label url
for item in "${checks[@]}"; do
label="${item%%:*}"
url="${item#*:}"
if check_http "${url}"; then
echo " [✓] ${label} 可访问"
if [[ "${mode}" == "all" || -z "${mode}" ]]; then
total="${#PM2_APPS[@]}"
online="$(pm2_count_online)"
if [[ "${online}" -eq "${total}" ]]; then
echo " [✓] PM2 进程 ${online}/${total} online"
else
echo " [✗] ${label} 不可访问 (${url})"
echo " [✗] PM2 进程 ${online}/${total} online"
ok=0
pm2 list 2>/dev/null || true
fi
local checks=(
"中控:http://127.0.0.1:5100/"
"Binance:http://127.0.0.1:5001/"
"Gate:http://127.0.0.1:5000/"
"OKX:http://127.0.0.1:5004/"
)
local item label url
for item in "${checks[@]}"; do
label="${item%%:*}"
url="${item#*:}"
if check_http "${url}"; then
echo " [✓] ${label} 可访问"
else
echo " [✗] ${label} 不可访问 (${url})"
ok=0
fi
done
else
if ! ex_key="$(normalize_exchange_key "${mode}")"; then
echo " [✗] 未知验收模式: ${mode}"
return 1
fi
local pm2_name port label
pm2_name="$(exchange_pm2_name "${ex_key}")"
port="$(exchange_http_port "${ex_key}")"
label="$(exchange_label "${ex_key}")"
if pm2_app_exists "${pm2_name}"; then
echo " [✓] PM2 ${pm2_name} 已注册"
else
echo " [✗] PM2 缺少进程 ${pm2_name}"
ok=0
pm2 list 2>/dev/null || true
fi
if check_http "http://127.0.0.1:${port}/"; then
echo " [✓] ${label} 可访问 (http://127.0.0.1:${port}/)"
else
echo " [✗] ${label} 不可访问 (http://127.0.0.1:${port}/)"
ok=0
fi
done
fi
if [[ "${ok}" -eq 1 ]]; then
echo ""
@@ -410,3 +483,29 @@ print_post_install_guide() {
═══════════════════════════════════════════
EOF
}
print_post_install_guide_instance() {
local ex_key="$1"
local ip="${2:-$(detect_server_ip)}"
local label port
label="$(exchange_label "${ex_key}")"
port="$(exchange_http_port "${ex_key}")"
cat <<EOF
═══════════════════════════════════════════
✅ 单所实例部署完成(不含中控)
${label}: http://${ip}:${port}
登录账号: admin
登录密码: admin123
(请尽快在 env 配置中修改)
下一步(浏览器):
1. ${label} → env 配置 → 填 API、风控、企业微信
2. 开启实盘下单 → 保存并重启该实例进程
说明: 本模式不起中控 / agent;整仓仍在 ${INSTALL_ROOT},仅启动本所 Flask.
═══════════════════════════════════════════
EOF
}