Files
gold_monitor/deploy/lib/install.sh
T

37 lines
922 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
# shellcheck shell=bash
set -euo pipefail
# shellcheck source=common.sh
source "${LIB_DIR}/common.sh"
need_root
echo "[1/4] 安装系统依赖 / venv ..."
bash "${REPO_ROOT}/deploy/setup_env.sh"
echo "[2/4] 安装 Node / PM2 ..."
ensure_node_pm2
echo "[3/4] 启动 PM2 ..."
cd "${REPO_ROOT}"
pm2 delete gold_monitor >/dev/null 2>&1 || true
pm2 start "${REPO_ROOT}/deploy/ecosystem.config.cjs"
pm2 save
pm2 startup systemd -u root --hp /root >/dev/null 2>&1 || true
echo "[4/4] 验收 ..."
sleep 2
IP="$(detect_server_ip)"
if verify_http "http://127.0.0.1:5800/health"; then
echo "✓ 健康检查通过"
else
echo "✗ 健康检查失败,请执行: pm2 logs gold_monitor" >&2
exit 1
fi
echo ""
echo "部署完成"
echo " 地址: http://${IP}:5800"
echo " 登录: admin / admin123 (请立即修改 .env 中 ADMIN_PASSWORD)"
echo " 管理: bash ${REPO_ROOT}/deploy/manage.sh"
echo ""