Add MQTT webhook bridge with resilient MQTT connection handling
FastAPI service that subscribes to nearle/# on the MQTT broker and forwards rider status, periodic logs, and profile updates to the Jupiter webhook API. Includes fixes for a failure mode that took the bridge down silently for ~3.8 days in June 2026, during which it served HTTP 200 on / while forwarding zero events: - Retry MQTT connection with backoff instead of letting a single failed connect kill the background thread permanently. - Subscribe inside on_connect so subscriptions are restored after an automatic reconnect; the session is clean, so a reconnect previously came back subscribed to nothing. - Add /healthz returning 503 when MQTT is disconnected, so a monitor can distinguish a live bridge from a dead one. - Replace thread-per-message forwarding with a bounded worker pool, which keeps memory flat when the upstream API stalls on its 5s timeout. - Pin requirements.txt to the versions verified in production; it was unpinned and had already drifted to paho-mqtt 2.1.0. - Set PYTHONUNBUFFERED so container logs are not block-buffered. - Name the compose image nearle-api-image to match the deployed tag. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
7
requirements.txt
Normal file
7
requirements.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
# Pinned to the versions verified running in production on 2026-07-27.
|
||||
# Previously unpinned, so every rebuild silently pulled whatever was latest.
|
||||
fastapi==0.128.8
|
||||
uvicorn==0.39.0
|
||||
paho-mqtt==2.1.0
|
||||
requests==2.32.5
|
||||
pydantic==2.12.5
|
||||
Reference in New Issue
Block a user