From 732c626ef98be72c3b10c4e65557bc1fd8c41267 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Sep 2026 17:18:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=20worker=20HEALTH?= =?UTF-8?q?CHECK=20=E5=BC=95=E5=8F=B7=E5=B5=8C=E5=A5=97=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 4 个脚本中 5 处 sh -c for 循环健康检查命令替换为简洁的 grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1 原写法中嵌套双引号导致 $pid 不被展开为变量, grep 始终匹配字面量 $pid 而非实际进程路径, healthcheck 永远返回 exit code 1,容器被误判为 unhealthy。 受影响文件: - scripts/ci_staging_healthcheck.sh - scripts/ci_staging_deploy.sh (2处) - scripts/ci_production_healthcheck.sh - scripts/rollback_production.sh --- scripts/ci_production_healthcheck.sh | 2 +- scripts/ci_staging_deploy.sh | 4 ++-- scripts/ci_staging_healthcheck.sh | 2 +- scripts/rollback_production.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/ci_production_healthcheck.sh b/scripts/ci_production_healthcheck.sh index 3b311904c..b38c40c2e 100644 --- a/scripts/ci_production_healthcheck.sh +++ b/scripts/ci_production_healthcheck.sh @@ -310,7 +310,7 @@ docker run -d \ --restart unless-stopped \ --cpus 2 \ --memory 2g \ - --health-cmd "sh -c \"for pid in /proc/[0-9]*/cmdline; do if grep -ql celery \"$pid\" 2>/dev/null; then exit 0; fi; done; exit 1\"" \ + --health-cmd "grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \ diff --git a/scripts/ci_staging_deploy.sh b/scripts/ci_staging_deploy.sh index 60950c81f..856bc6b54 100755 --- a/scripts/ci_staging_deploy.sh +++ b/scripts/ci_staging_deploy.sh @@ -192,7 +192,7 @@ rollback() { -e PUBLIC_API_BASE_URL=https://staging-api.xiaoxiajianji.com \ -v "$GENERATED_DIR:/app/generated" \ --restart unless-stopped \ - --health-cmd "sh -c \"for pid in /proc/[0-9]*/cmdline; do if grep -ql celery \"\$pid\" 2>/dev/null; then exit 0; fi; done; exit 1\"" \ + --health-cmd "grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \ @@ -504,7 +504,7 @@ docker run -d \ -e PUBLIC_API_BASE_URL=https://staging-api.xiaoxiajianji.com \ -v "$GENERATED_DIR:/app/generated" \ --restart unless-stopped \ - --health-cmd "sh -c \"for pid in /proc/[0-9]*/cmdline; do if grep -ql celery \"\$pid\" 2>/dev/null; then exit 0; fi; done; exit 1\"" \ + --health-cmd "grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \ diff --git a/scripts/ci_staging_healthcheck.sh b/scripts/ci_staging_healthcheck.sh index 79a63b00e..25808ec1e 100644 --- a/scripts/ci_staging_healthcheck.sh +++ b/scripts/ci_staging_healthcheck.sh @@ -305,7 +305,7 @@ docker run -d \ -e PUBLIC_API_BASE_URL=https://staging-api.xiaoxiajianji.com \ -v "$GENERATED_DIR:/app/generated" \ --restart unless-stopped \ - --health-cmd "sh -c \"for pid in /proc/[0-9]*/cmdline; do if grep -ql celery \"$pid\" 2>/dev/null; then exit 0; fi; done; exit 1\"" \ + --health-cmd "grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \ diff --git a/scripts/rollback_production.sh b/scripts/rollback_production.sh index 4e4d3f59c..0e4806318 100755 --- a/scripts/rollback_production.sh +++ b/scripts/rollback_production.sh @@ -201,7 +201,7 @@ docker run -d \ --restart unless-stopped \ --cpus 2 \ --memory 2g \ - --health-cmd "sh -c \"for pid in /proc/[0-9]*/cmdline; do if grep -ql celery \"$pid\" 2>/dev/null; then exit 0; fi; done; exit 1\"" \ + --health-cmd "grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \ -- 2.54.0