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:
+81
-11
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy/lib/install.sh — 一键部署
|
||||
# deploy/lib/install.sh — 一键部署(全套) / 单所仅实例
|
||||
set -e
|
||||
set -u
|
||||
if [ -n "${BASH_VERSION:-}" ]; then
|
||||
@@ -10,6 +10,26 @@ LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=common.sh
|
||||
source "${LIB_DIR}/common.sh"
|
||||
|
||||
EXCHANGE=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--exchange)
|
||||
EXCHANGE="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
echo "用法: bash deploy/lib/install.sh [--exchange okx|binance|gate]"
|
||||
echo " 无 --exchange: 全套(三所+中控)"
|
||||
echo " 有 --exchange: 仅该所 Flask 实例(不含中控/agent)"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "未知参数: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
install_fresh() {
|
||||
step "克隆仓库"
|
||||
if [[ -d "${INSTALL_ROOT}" ]]; then
|
||||
@@ -45,6 +65,28 @@ run_install_pipeline() {
|
||||
print_post_install_guide "$(detect_server_ip)"
|
||||
}
|
||||
|
||||
run_instance_pipeline() {
|
||||
local ex_key="$1"
|
||||
local dir_name
|
||||
dir_name="$(exchange_dir "${ex_key}")"
|
||||
|
||||
step "单所环境部署 setup_env.sh --only ${ex_key}(不含中控)"
|
||||
bash "${REPO_ROOT}/deploy/setup_env.sh" --only "${ex_key}" --install-system-deps
|
||||
|
||||
step "启动 PM2 仅 ${dir_name}"
|
||||
bash "${REPO_ROOT}/deploy/pm2_start_all.sh" --only "${ex_key}"
|
||||
|
||||
pm2_save_startup
|
||||
local cron_script="${REPO_ROOT}/${dir_name}/scripts/install_backup_cron.sh"
|
||||
if [[ -x "${cron_script}" ]]; then
|
||||
step "安装 ${ex_key} 备份 cron"
|
||||
bash "${cron_script}" || true
|
||||
fi
|
||||
|
||||
verify_deployment "$(detect_server_ip)" "${ex_key}" || true
|
||||
print_post_install_guide_instance "${ex_key}" "$(detect_server_ip)"
|
||||
}
|
||||
|
||||
handle_existing_install() {
|
||||
echo ""
|
||||
echo "检测到已部署安装: ${INSTALL_ROOT}"
|
||||
@@ -72,10 +114,47 @@ handle_existing_install() {
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_repo_ready() {
|
||||
if repo_ready "${INSTALL_ROOT}"; then
|
||||
REPO_ROOT="${INSTALL_ROOT}"
|
||||
elif [[ -n "${REPO_ROOT:-}" ]] && repo_ready "${REPO_ROOT}"; then
|
||||
:
|
||||
else
|
||||
REPO_ROOT=""
|
||||
fi
|
||||
|
||||
if [[ -z "${REPO_ROOT}" ]]; then
|
||||
install_system_packages
|
||||
install_node_pm2
|
||||
install_fresh
|
||||
REPO_ROOT="${INSTALL_ROOT}"
|
||||
else
|
||||
install_system_packages
|
||||
install_node_pm2
|
||||
fi
|
||||
}
|
||||
|
||||
main_install_instance() {
|
||||
local ex_key="$1"
|
||||
require_root
|
||||
require_ubuntu
|
||||
ensure_repo_ready
|
||||
run_instance_pipeline "${ex_key}"
|
||||
}
|
||||
|
||||
main_install() {
|
||||
require_root
|
||||
require_ubuntu
|
||||
|
||||
if [[ -n "${EXCHANGE}" ]]; then
|
||||
local ex_key=""
|
||||
if ! ex_key="$(normalize_exchange_key "${EXCHANGE}")"; then
|
||||
die "无效 --exchange: ${EXCHANGE} (期望 okx|binance|gate)"
|
||||
fi
|
||||
main_install_instance "${ex_key}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if repo_ready "${INSTALL_ROOT}"; then
|
||||
REPO_ROOT="${INSTALL_ROOT}"
|
||||
elif repo_ready "${REPO_ROOT}"; then
|
||||
@@ -89,16 +168,7 @@ main_install() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -z "${REPO_ROOT}" ]]; then
|
||||
install_system_packages
|
||||
install_node_pm2
|
||||
install_fresh
|
||||
REPO_ROOT="${INSTALL_ROOT}"
|
||||
else
|
||||
install_system_packages
|
||||
install_node_pm2
|
||||
fi
|
||||
|
||||
ensure_repo_ready
|
||||
run_install_pipeline
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user