Skip to main content

Liveness and readiness HTTP probes with StatsD worker gauges for Gevent and Gunicorn.

Project description

Healthcheck

CI PyPI publish License: MIT

Healthcheck is a small sidecar-style process that exposes liveness and readiness HTTP endpoints. It listens for StatsD-style UDP gauges (for example gunicorn.workers) so the HTTP layer can reflect how many workers are alive.

Requirements

  • Python 3.12 or newer

Install

From PyPI:

pip install approck-healthcheck

The importable Python package remains healthcheck (for example python -m healthcheck, from healthcheck.application import create_application).

From a git checkout with uv:

uv sync --locked
uv run healthcheck --help

Run

uv run healthcheck --host 0.0.0.0 --port 8001
# or
python -m healthcheck --host 0.0.0.0 --port 8001

Integrations

Gevent

The healthcheck CLI starts a Gevent WSGIServer for /health/* and a UDP StatsD listener on the configured host and port. Your workers (or Gunicorn hooks) should emit gauge metrics named workers or gunicorn.workers so liveness reflects the worker count.

Gunicorn

Add Gunicorn hooks to your gunicorn.conf.py:

from healthcheck.gunicorn.hooks import *

# gunicorn.conf.py goes here
# ...

Command line

usage: healthcheck [-h] [-H HOST] [-P PORT] [--statsd-host STATSD_HOST]
                   [--statsd-port STATSD_PORT]
                   [--application-health-ready-url URL] [-v]

A simple "sidecar" healthcheck application. It uses the statsD protocol over
UDP to receive metrics and provides liveness and readiness HTTP endpoints.

options:
  -h, --help            show this help message and exit
  -H HOST, --host HOST  The host that the server should bind on (default:
                        localhost).
  -P PORT, --port PORT  The port that the server should bind on (default:
                        8000).
  --statsd-host STATSD_HOST
                        The host of the statsd server (default: localhost).
  --statsd-port STATSD_PORT
                        The port of the statsd server (default: 8125).
  --application-health-ready-url URL
                        The application URL which provides a readiness status
                        (optional).
  -v, --verbose         Activate verbose output to the console and specify the
                        level of detail.

REST API

  • GET /health/live

    Liveness probe — indicates whether the process considers workers available.

    Status codes:

    • 200 — workers gauge is positive.
    • 422 — no workers reported (NoWorkers).

    Error JSON:

    • code (string), e.g. NoWorkers.
    • description (string).
  • GET /health/ready

    Readiness probe — same worker gate as liveness; if --application-health-ready-url is set, the handler proxies JSON from that URL or returns ServiceNotReady on non-200 responses.

    Status codes:

    • 200 — ready (including proxied JSON from the application URL when configured).
    • 422 — not ready.

Development

Clone the repository, then install dependencies (uses the committed uv.lock) and run checks:

uv sync --locked
uv run ruff check healthcheck tests
uv run ruff format --check healthcheck tests
uv run pytest

To refresh dev dependencies and regenerate the lockfile:

uv lock --upgrade

To apply Ruff formatting (instead of only checking):

uv run ruff format healthcheck tests

Contributing

Issues and pull requests (including from forks) are welcome. Please run uv run ruff check, uv run ruff format --check, and uv run pytest before submitting a change.

License

MIT — see LICENSE.

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

approck_healthcheck-1.0.13.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

approck_healthcheck-1.0.13-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file approck_healthcheck-1.0.13.tar.gz.

File metadata

  • Download URL: approck_healthcheck-1.0.13.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for approck_healthcheck-1.0.13.tar.gz
Algorithm Hash digest
SHA256 17ee7c24dcf4ae9263a338e2713748175fe567abdc8d7599f5887a57f96e5550
MD5 d50a81dd0919575b76e28cd52a52cff3
BLAKE2b-256 9418ca6bf857778c1bed1e8fcf9bd99798974022d0b62fb815179cddbfc03c2f

See more details on using hashes here.

File details

Details for the file approck_healthcheck-1.0.13-py3-none-any.whl.

File metadata

  • Download URL: approck_healthcheck-1.0.13-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for approck_healthcheck-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 9fe42bfb93194ee8fa08eb65f9de8bfe45004af99204b60336560620cfd3ca33
MD5 8e4046fff103d64e99b7d1fe035e2116
BLAKE2b-256 d86ad3b5a4fb30031144539f459b47183ea416ca3a22d717a72ec941bafec385

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