exobrain-health
Heartbeat-based HTTP health probe for MyExobrain background workers
(exobrain-orchestrator, exobrain-actions, exobrain-deployment-risk).
Azure Container Apps only supports HTTP(S) and TCP probes. A TCP probe can't detect a worker
whose main loop is stuck (the kernel still accepts connections), so each worker exposes
GET /health on an internal port, backed by a heartbeat written by its main loop.
How it works
┌──────────── worker process ──────────────┐
│ main thread: worker loop │──► state.heartbeat() on every iteration
│ │
│ daemon thread: uvicorn + FastAPI │──► GET /health reads state.snapshot()
└──────────────────────────────────────────┘
- The endpoint makes no network, Redis or database call: it reads the in-memory
HealthStateshared by reference with the worker loop (both run in the same process). statusis computed from the age of the last heartbeat (monotonic clock):
| Status | HTTP | Condition |
|---|---|---|
starting |
503 | no heartbeat yet (worker still initializing) |
ok |
200 | last heartbeat age ≤ max_heartbeat_age |
stale |
503 | last heartbeat age > max_heartbeat_age (stuck) |
Example response:
{"status": "ok", "last_heartbeat_age_s": 0.42, "max_heartbeat_age_s": 60.0, "uptime_s": 3600.1, "version": "5.6.0"}
Usage
exobrain.health is a PEP 420 namespace package:
from exobrain.health import HealthServer, HealthSettings, HealthState
settings = HealthSettings.from_env(default_max_heartbeat_age=60)
state = HealthState(settings.max_heartbeat_age)
if settings.enabled:
HealthServer(state, port=settings.port, version="1.0.0").start()
while not should_stop:
state.heartbeat()
... # one iteration of the worker loop
A service that already runs a FastAPI application can mount create_health_router(state) instead.
Environment variables
| Variable | Default | Description |
|---|---|---|
HEALTH_ENABLED |
true |
Start the health server |
HEALTH_PORT |
8080 |
Listening port |
HEALTH_MAX_HEARTBEAT_AGE |
caller default | Seconds without heartbeat before /health fails |
Azure Container Apps probes
No ingress is needed: probes reach the container port directly.
| Probe | Path | Port | Period | Failure threshold |
|---|---|---|---|---|
| Startup | /health |
8080 | 10 s | 30 |
| Liveness | /health |
8080 | 20 s | 3 |
Development
Install uv and Hatch (once, as a uv tool), then the development environment:
uv tool install hatch
uv sync
Before committing, run the tests and the quality checks with Hatch. Use --fix with code and
fmt to let Ruff fix the issues instead of only reporting them:
uv run pytest # unit tests
hatch check code --fix # lint (Ruff, settings from [tool.ruff])
hatch check fmt --fix # format (Ruff)
hatch check types # type check (mypy, strict)
hatch check # all the checks, without fixing
The build workflow runs the unit tests and hatch check on every push to main and development.
On pull requests, only the issues located on changed lines are reported (as annotations) and fail
the build.
Pushing a vX.Y.Z tag matching the project version builds the package and publishes it to PyPI
(publish workflow).
License
Private project, all rights reserved: see LICENSE.md.
Metadata
Release files for exobrain-health 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| exobrain_health-0.1.0.tar.gz | 28.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| exobrain_health-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.2 kB
Release files / exobrain_health-0.1.0.tar.gz
| Download URL | exobrain_health-0.1.0.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27faa5266c033605478637271eeff4addcdecaa159f2e26dbfe510ce16a1e84f
|
|
BLAKE2b-256 checksum How to use checksums |
43c1d9b1a50668add3b7fd3f7daf51940c02573f04e329821c33d01c535e3b7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / exobrain_health-0.1.0-py3-none-any.whl
| Download URL | exobrain_health-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
295362868db5bd7cb77cf6fc6c0ff071212e2c5e8fefb8d5c7aa98e2146739f0
|
|
BLAKE2b-256 checksum How to use checksums |
db66dfe2e6e365e1babc6aef3e83cdb13ebfc01495b7a553b8a095f170940c39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for exobrain-health 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.