Skip to main content

celery-uptime

celery-uptime adds lightweight HTTP health and readiness endpoints to Celery workers and beat without changing the Celery command you already run.

from celery import Celery
from celery_uptime import monitor

app = Celery("my-service", broker="sqs://", backend="redis://redis:6379/0")

monitor(app)

Then keep your normal command:

celery -A my_service.celery_app worker --loglevel=info

The package starts an embedded Uvicorn server from Celery lifecycle signals. It starts on worker_ready for workers and beat_init for beat.

Installation

The base package only installs Celery, FastAPI, and Uvicorn. Install the extras matching the providers your Celery app already uses:

pip install "celery-uptime[redis,sqs]"

Available extras:

  • redis: Redis broker/backend and Redis Sentinel.
  • sqs: SQS broker.
  • kafka: Kafka broker through Kombu's Confluent Kafka transport.
  • sqlalchemy: SQLAlchemy/database result backend.
  • django: Django database/cache result backends.
  • mongodb: MongoDB result backend.
  • elasticsearch: Elasticsearch result backend.
  • cassandra: Cassandra result backend.
  • memcache: Memcached cache result backend.
  • all: all optional provider dependencies.

Missing provider dependencies do not crash the monitor. /ready returns a failing check with details such as missing_extra:mongodb.

Endpoints

  • GET /health: returns process/server liveness.
  • GET /ready: returns Celery process readiness plus broker/backend checks.

Example /ready response:

{
  "status": "ok",
  "service": "my-service-celery-worker",
  "process": "worker",
  "checks": {
    "celery_process": {"status": "ok", "detail": "ready"},
    "broker": {"status": "ok", "detail": "ok"},
    "backend": {"status": "ok", "detail": "ok"}
  }
}

Configuration

Environment variables:

  • CELERY_UPTIME_ENABLED=true
  • CELERY_UPTIME_HOST=0.0.0.0
  • CELERY_UPTIME_PORT=8090
  • CELERY_UPTIME_SERVICE=<celery app main>-celery-<worker|beat>
  • CELERY_UPTIME_LOG_LEVEL=warning
  • CELERY_UPTIME_CHECK_INTERVAL=30
  • CELERY_UPTIME_CHECK_TIMEOUT=5
  • CELERY_UPTIME_STALE_AFTER=90

Docker Compose example:

services:
  celery-worker:
    command: ["celery", "-A", "my_service.celery_app", "worker", "--loglevel=info"]
    environment:
      - CELERY_UPTIME_PORT=8090
    ports:
      - "49211:8090"
    healthcheck:
      test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8090/health', timeout=5).read()\" || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

If your image includes curl, the healthcheck can be shorter:

services:
  celery-worker:
    healthcheck:
      test: ["CMD-SHELL", "curl -fsS --max-time 5 http://127.0.0.1:8090/health > /dev/null || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

Use /health for Docker/container liveness. It does not run broker/backend checks and is the safer endpoint for long-running task workers. Use /ready from external monitoring systems such as Uptime Kuma when you want dependency visibility and alerting. Avoid wiring /ready failures directly to automatic worker restarts unless your task loss/retry behavior is intentionally designed for that.

External readiness check examples:

curl -fsS --max-time 5 http://127.0.0.1:8090/health
curl -fsS --max-time 5 http://127.0.0.1:8090/ready

/ready is served from a cache populated by a background probe loop, so HTTP requests do not block on broker/backend clients. Before the first probe it returns 503 with detail: "not_checked_yet". If the cached probe result is older than CELERY_UPTIME_STALE_AFTER, it returns 503 with detail: "stale".

Automatic Checks

monitor(app) automatically detects:

  • RabbitMQ/AMQP broker: amqp://, pyamqp://, librabbitmq://.
  • Redis broker/backend: redis://, rediss://.
  • Redis Sentinel broker/backend: sentinel:// with master_name.
  • SQS broker: sqs:// with broker_transport_options.
  • Kafka broker: kafka://, confluentkafka://.
  • SQLAlchemy/database backend: db+..., database+....
  • Django backend conventions: django-db, django-cache.
  • RPC backend: rpc://, checked through broker connectivity.
  • Memcached backend: cache+memcached://, cache+pymemcache://, cache+pylibmc://.
  • MongoDB backend: mongodb://, mongodb+srv://.
  • Elasticsearch backend: elasticsearch://.
  • Cassandra backend: cassandra://.

No result backend is valid Celery configuration. If result_backend is absent or disabled://, /ready reports the backend as healthy and non-required:

{"status": "ok", "detail": "disabled", "required": false}

Unsupported providers outside this classic set fail closed in /ready unless you replace them with explicit checks.

Explicit Checks

For unusual apps, pass explicit checks:

from celery_uptime import database_check, monitor, redis_check, sqs_check

monitor(
    app,
    checks=[
        sqs_check(
            "broker",
            endpoint_url="https://sqs.fr-par.scw.cloud",
            region="fr-par",
            queue_url="https://sqs.fr-par.scw.cloud/queue",
            access_key="...",
            secret_key="...",
        ),
        redis_check("backend", "redis://redis:6379/0"),
        database_check("reporting-db", "postgresql://user:password@db:5432/app"),
    ],
    include_auto_checks=False,
)

Provider checks are connection-only. They do not write/read/delete Celery result records or mutate broker/backend data.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celery_uptime-0.0.3.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

celery_uptime-0.0.3-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file celery_uptime-0.0.3.tar.gz.

File metadata

  • Download URL: celery_uptime-0.0.3.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for celery_uptime-0.0.3.tar.gz
Algorithm Hash digest
SHA256 94d0acdf21ea7c8d7e262519247c8c0ac9a500da42092b1fdbdbb266d7d6a16d
MD5 7d6b767b95e5d6f46924f5b9855a752d
BLAKE2b-256 85af89c064a836d327408afebc2a23cfd30210417146887fbffb0f85f55dddd6

See more details on using hashes here.

File details

Details for the file celery_uptime-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: celery_uptime-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for celery_uptime-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 14a6abf25ea0cac49ab031291889692d601da235e13e18c50e9088a051ced350
MD5 0f2f0bc19af63d876c42fd53990e60e4
BLAKE2b-256 4f290fc40b84da40bde2f979fa86dc68acec38da2a234375753e2fd1b00534fb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page