Description
Our platform relies on Celery Beat to trigger lead processing every minute. If Celery Beat hangs or crashes, outreach sequences stop running silently. We need a health-check endpoint that verifies if the cron runner is alive.
User & Contributor Value
- Contributors: Caching state checks, background heartbeat updates, and creating systems monitoring APIs.
- Users: Enables devops teams to monitor schedule health and auto-restart stuck worker containers.
Code Locations
- backend/backend/urls.py
- backend/campaigns/tasks.py
Implementation Guide
- Heartbeat Task: Write a simple periodic task
celery_heartbeat() that runs every minute, updating a Redis/Cache key celery_beat_heartbeat with the current timestamp.
- API View: Add a route
/api/v1/health/celery-beat/. It should check if the cache key exists and is less than 3 minutes old, returning HTTP 200 (healthy) or HTTP 503 (stuck).
Description
Our platform relies on Celery Beat to trigger lead processing every minute. If Celery Beat hangs or crashes, outreach sequences stop running silently. We need a health-check endpoint that verifies if the cron runner is alive.
User & Contributor Value
Code Locations
Implementation Guide
celery_heartbeat()that runs every minute, updating a Redis/Cache keycelery_beat_heartbeatwith the current timestamp./api/v1/health/celery-beat/. It should check if the cache key exists and is less than 3 minutes old, returning HTTP 200 (healthy) or HTTP 503 (stuck).