From 99643d25abc945eba10a8d40019fe0e7fbc1307e Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Sun, 26 Jul 2026 23:31:07 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20worker=20healthcheck=20=E2=80=94=20Redis?= =?UTF-8?q?=20ping=20instead=20of=20HTTP=20check=20for=20worker=20containe?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- healthcheck.sh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 healthcheck.sh diff --git a/Dockerfile b/Dockerfile index 42c2fda..246abc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,7 @@ COPY --chown=appuser:appuser . . COPY --from=frontend --chown=appuser:appuser /frontend/dist /app/frontend/dist # Make entrypoint scripts executable -RUN chmod +x /app/prestart.sh /app/worker.sh +RUN chmod +x /app/prestart.sh /app/worker.sh /app/healthcheck.sh # Create storage directory RUN mkdir -p /data/storage && chown -R appuser:appuser /data @@ -86,6 +86,6 @@ USER appuser EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ - CMD curl -fsS http://localhost:8000/api/v1/health || exit 1 + CMD /app/healthcheck.sh ENTRYPOINT ["/app/prestart.sh"] diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100644 index 0000000..59568e6 --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# LeoCRM Healthcheck — works for both web server and worker containers. +# If port 8000 is listening → HTTP health check. +# Otherwise (worker) → Redis ping check. + +if curl -fsS http://localhost:8000/api/v1/health > /dev/null 2>&1; then + exit 0 +fi + +# No web server — check Redis connectivity (worker mode) +python3 -c " +import os, sys +import redis +try: + r = redis.from_url(os.environ.get('REDIS_URL', 'redis://localhost:6379/0')) + r.ping() + sys.exit(0) +except Exception: + sys.exit(1) +" 2>/dev/null || exit 1