From b1faced2f5789472623a16b4428ef326b7c3b646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Tue, 23 Jun 2026 16:54:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(update):=20=E6=94=B9=E7=94=A8=20compose=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=20bugcollect-service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前两次修复均依赖历史容器(docker ps -a),在旧部署从未运行过 bugcollect 的情况下无法检测。 改为检查 docker-compose.yml 是否定义了 bugcollect-service: - profile 激活:有定义即导出 COMPOSE_PROFILES=bugcollect - 服务重启:有定义即直接 up,不依赖容器历史状态 Co-Authored-By: Claude Sonnet 4.6 --- scripts/update.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 9c916e2..c3e7ee3 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -139,12 +139,12 @@ ok "NGINX_BIND=${_NGINX_BIND}" [ -n "$_CONSOLE_DOMAIN" ] || fail "config/xuqm.env 中 CONSOLE_DOMAIN 未设置,请手动补充后重试" -# 检测可选 profile 容器(含已停止),升级时保持 profile 激活状态, -# 避免 docker compose --remove-orphans 把 profile 容器当孤儿停掉 +# 若 docker-compose.yml 包含 bugcollect-service 定义,激活 bugcollect profile, +# 确保 --remove-orphans 不把该服务的容器当孤儿停掉 _ACTIVE_PROFILES="" -if docker ps -a --format '{{.Names}}' 2>/dev/null | grep -qi 'bugcollect'; then +if grep -q 'bugcollect-service:' "$ROOT_DIR/docker-compose.yml" 2>/dev/null; then _ACTIVE_PROFILES="bugcollect" - ok "检测到 bugcollect-service(含已停止)→ 激活 bugcollect profile" + ok "docker-compose.yml 包含 bugcollect-service → 激活 bugcollect profile" fi export COMPOSE_PROFILES="${_ACTIVE_PROFILES}" @@ -506,15 +506,17 @@ for _svc in tenant-service im-service file-service update-service license-servic fi done -# bugcollect-service / symbolicator 是 profile 服务,需单独处理: -# 用 docker ps -a 检测历史容器(含已停止),存在即重启,确保升级不漏掉 -for _svc in bugcollect-service symbolicator; do - if docker ps -a --format '{{.Names}}' 2>/dev/null | grep -qi "${_svc}"; then +# bugcollect-service / symbolicator 是 profile 服务,需单独处理。 +# 判断依据:docker-compose.yml 中是否定义了 bugcollect-service(而非历史容器是否存在)。 +# 旧部署首次引入此服务时没有历史容器,必须用 compose 文件判断。 +if grep -q 'bugcollect-service:' "$ROOT_DIR/docker-compose.yml" 2>/dev/null; then + for _svc in bugcollect-service symbolicator; do info "应用新镜像并重启 ${_svc} ..." - COMPOSE_PROFILES=bugcollect $_COMPOSE up -d --no-deps "$_svc" - ok "${_svc} 已更新" - fi -done + COMPOSE_PROFILES=bugcollect $_COMPOSE up -d --no-deps "$_svc" \ + && ok "${_svc} 已更新" \ + || warn "${_svc} 启动失败,请检查: docker compose logs ${_svc}" + done +fi # 确保 nginx 在运行(一键更新时可能因 --remove-orphans 时序问题导致 nginx 被停掉) if ! $_COMPOSE ps --services --filter status=running 2>/dev/null | grep -q "^nginx$"; then