From 20800e877ed88cd1c7f99ec5bef044b9846b2418 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 08:42:55 +0000 Subject: [PATCH] =?UTF-8?q?refactor(proxy):=20=E6=8F=90=E5=8F=96PM2?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=80=BB=E8=BE=91=E5=88=B0=20start=5Fpm2=5Fs?= =?UTF-8?q?ervices()=20=E6=B6=88=E9=99=A4=E9=87=8D=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update() 和 restart() 共用 start_pm2_services() 函数, 该函数统一使用 pm2 startOrRestart --update-env 处理启动和重启。 Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/c15b16e7-9f03-4f45-9c83-4e8fe1583aa6 Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- server/proxy/deploy-proxy.sh | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/server/proxy/deploy-proxy.sh b/server/proxy/deploy-proxy.sh index c332cb27..c44d1c6c 100644 --- a/server/proxy/deploy-proxy.sh +++ b/server/proxy/deploy-proxy.sh @@ -223,7 +223,8 @@ configure_nginx() { fi } -# ── 启动PM2服务 ─────────────────────────────── +# ── 启动/重启PM2服务 ────────────────────────── +# 使用 pm2 startOrRestart 统一处理(已注册→重启,未注册→启动) start_pm2_services() { cd "$PROXY_DIR" || { echo "❌ 无法进入 $PROXY_DIR"; return 1; } @@ -235,9 +236,9 @@ start_pm2_services() { set +a fi - pm2 start ecosystem.proxy.config.js + pm2 startOrRestart ecosystem.proxy.config.js --update-env pm2 save - echo "✅ PM2代理服务已启动" + echo "✅ PM2代理服务已就绪" pm2 list } @@ -316,18 +317,8 @@ update() { systemctl restart xray - # PM2代理服务: 使用 startOrRestart 统一处理(已注册→重启,未注册→启动) - cd "$PROXY_DIR" || { echo "❌ 无法进入 $PROXY_DIR"; return 1; } - if [ -f "$PROXY_DIR/.env.keys" ]; then - set -a - # shellcheck source=/dev/null - source "$PROXY_DIR/.env.keys" - set +a - fi - pm2 startOrRestart ecosystem.proxy.config.js --update-env - pm2 save - echo "✅ PM2代理服务已更新" - pm2 list + # PM2代理服务 + start_pm2_services health_check echo "✅ 更新完成" @@ -342,17 +333,8 @@ status() { restart() { echo "重启所有代理服务..." systemctl restart xray - # PM2代理服务: 使用 startOrRestart 统一处理 - cd "$PROXY_DIR" || { echo "❌ 无法进入 $PROXY_DIR"; return 1; } - if [ -f "$PROXY_DIR/.env.keys" ]; then - set -a - # shellcheck source=/dev/null - source "$PROXY_DIR/.env.keys" - set +a - fi - pm2 startOrRestart ecosystem.proxy.config.js --update-env - pm2 save - echo "✅ PM2代理服务已重启" + # PM2代理服务 + start_pm2_services sleep 3 health_check }