Skip to main content

A lightweight HTTP health check server for Celery workers, designed to work with cloud platforms that only support TCP-based health probes

Project description

Celery Healthcheck

A lightweight HTTP health check server for Celery workers, designed to work with cloud platforms like Azure that only support TCP-based health probes.

Problem

When deploying Celery workers to cloud platforms like Azure, you need a way to verify the worker's health. However, Azure doesn't allow command execution for health checks and only supports TCP-based probes. This makes it challenging to properly monitor Celery workers.

Solution

celery-healthcheck spins up a small FastAPI server within each Celery worker that exposes an HTTP endpoint to check the worker's health status. This allows cloud platforms to perform health checks via HTTP requests rather than command execution.

Installation

pip install celery-healthcheck

Usage

Add the health check server to your Celery application:

from celery import Celery
import celery_healthcheck

app = Celery('myapp')
app.config_from_object('myapp.celeryconfig')

# Register the health check server
celery_healthcheck.register(app)

# Now start your worker as usual
# celery -A myapp worker -l info

How It Works

The health check server:

  1. Embeds a FastAPI application inside your Celery worker
  2. Runs on port 9000 by default (configurable)
  3. Exposes an HTTP endpoint (GET /) that:
    • Uses Celery's inspect API to ping the worker
    • Returns a JSON response with status and result

API Endpoints

GET /

Pings the Celery worker and returns its status.

Response:

{
  "status": "ok",  // or "error" if worker doesn't respond
  "result": { ... } // Raw response from Celery's ping command
}

Azure Configuration

When configuring Azure health probes:

  1. Set the probe to use HTTP
  2. Point to port 9000
  3. Use the path "/"
  4. A 200 OK response indicates the worker is healthy

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

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

Source Distribution

celery_healthcheck-0.1.1.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

celery_healthcheck-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file celery_healthcheck-0.1.1.tar.gz.

File metadata

  • Download URL: celery_healthcheck-0.1.1.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for celery_healthcheck-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3b3f14087f939c4bd5c16c0d3275a03cb20b7a926880a8421ab84c253947d54a
MD5 7f8af6e64ae8f6e7e427cbf22b3a0e2a
BLAKE2b-256 b023d80da2a9ba9dc83b136fbed9caa7f936e88fbc86409c44eb360d66c278c2

See more details on using hashes here.

File details

Details for the file celery_healthcheck-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for celery_healthcheck-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf324b0e6ba02fc1de125fa7b37e62edc4d0c1fb7c06eebd6d49777013638f8
MD5 fe1e5011b4071e5ed37f3face0d6d854
BLAKE2b-256 880e2536a6bf4c6c7ffe23406c3330ee43e24db7ffd492ddfc6f9ae375cf24fe

See more details on using hashes here.

Supported by

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