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 (after you publish a release):

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.

Publishing to PyPI

Project on PyPI: approck-healthcheck.

PyPI uploads run from release.yml when a maintainer pushes a version tag (v*) to GitHub. Configure a pending trusted publisher on PyPI for this repository and workflow file release.yml, with GitHub Environment name pypi (must match the workflow). Restrict the pypi environment with required reviewers if collaborators have write access.

Local build:

uv build

You can still upload dist/* manually with twine if you prefer.

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.12.tar.gz (6.9 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.12-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: approck_healthcheck-1.0.12.tar.gz
  • Upload date:
  • Size: 6.9 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.12.tar.gz
Algorithm Hash digest
SHA256 8c609f6598a1c1054dffbc5c9b9843ad8444b423847a7e0281cf1a3ba56ba219
MD5 177c0385cefd8920cb6b6082b856c873
BLAKE2b-256 8591fbc3fa8e0ec759688cc7505c22e5a507d3322132f13fb9f0717e15edd88a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: approck_healthcheck-1.0.12-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 40fa638cffb993fe1b33996617524fef1af1455d974107d871d7f76bc139ef17
MD5 93c512fced6ad06c88d598140a82573d
BLAKE2b-256 1d2a3dd6a5f09a79719fb72057a665dcf920c3ec4919937603ed7c6948a00cb6

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