diff --git a/infra/docker/compose.yml b/infra/docker/compose.yml index b0ce86443..46bfc0e74 100755 --- a/infra/docker/compose.yml +++ b/infra/docker/compose.yml @@ -128,9 +128,9 @@ services: - xiaoxia-net # 健康检查配置 - # 注:celery inspect ping 依赖 broker 连接,在容器内不可靠,改用进程检查 + # 注:容器内无 pgrep/ps,扫描 /proc 所有进程的 cmdline 查找 celery 进程 healthcheck: - test: ["CMD-SHELL", "for pid in /proc/[0-9]*/cmdline; do if grep -ql celery \"$pid\" 2>/dev/null; then exit 0; fi; done; exit 1"] + test: ["CMD-SHELL", "grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1"] interval: 30s timeout: 10s retries: 3 diff --git a/infra/docker/deploy-production-registry.sh b/infra/docker/deploy-production-registry.sh index e9a4a6a27..c0a78f05f 100755 --- a/infra/docker/deploy-production-registry.sh +++ b/infra/docker/deploy-production-registry.sh @@ -155,7 +155,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 "sh -c \"grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1\"" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \ diff --git a/infra/docker/deploy-staging-registry.sh b/infra/docker/deploy-staging-registry.sh index e7494c9b3..c5441d9f9 100755 --- a/infra/docker/deploy-staging-registry.sh +++ b/infra/docker/deploy-staging-registry.sh @@ -116,7 +116,7 @@ docker run -d \ -v "$GENERATED_DIR:/app/generated" \ --restart unless-stopped \ --label com.centurylinklabs.watchtower.enable=true \ - --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 "sh -c \"grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1\"" \ --health-interval 30s \ --health-timeout 10s \ --health-retries 3 \