diff --git a/scripts/update.sh b/scripts/update.sh index 67e56fa..7d3d520 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -447,13 +447,14 @@ _COMPOSE="docker compose --env-file ${ROOT_DIR}/.env \ # 使用 up -d 而非 restart:restart 只重启容器进程,不会切换到新拉取的镜像; # up -d 会检测镜像变更并重建容器,是应用新版本的正确方式。 -info "应用新镜像并重启 tenant-service ..." -$_COMPOSE up -d --no-deps --remove-orphans tenant-service -ok "tenant-service 已更新" - -info "应用新镜像并重启 nginx ..." -$_COMPOSE up -d --no-deps --remove-orphans nginx -ok "nginx 已更新" +for _svc in tenant-service im-service file-service update-service license-service push-service tenant-web nginx; do + # 仅重启已激活的服务(跳过未运行的可选服务) + if $_COMPOSE ps --services --filter status=running 2>/dev/null | grep -q "^${_svc}$"; then + info "应用新镜像并重启 ${_svc} ..." + $_COMPOSE up -d --no-deps --remove-orphans "$_svc" + ok "${_svc} 已更新" + fi +done # --------------------------------------------------------------------------- # Step 7 — 等待 tenant-service 健康