Skip to content

Commit 486b6db

Browse files
committed
Add RabbitMQ healthcheck
1 parent a05a823 commit 486b6db

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,12 @@ services:
599599
LOG_LEVEL: INFO
600600
networks:
601601
- fuzzforge-network
602+
healthcheck:
603+
test: ["CMD", "python", "healthcheck.py"]
604+
interval: 30s
605+
timeout: 5s
606+
retries: 3
607+
start_period: 10s
602608
restart: unless-stopped
603609

604610
# ============================================================================

services/ingestion_dispatcher/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ WORKDIR /app
66
COPY requirements.txt ./
77
RUN pip install --no-cache-dir -r requirements.txt
88

9-
COPY app.py ./
9+
COPY app.py healthcheck.py ./
1010

1111
CMD ["python", "app.py"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Simple healthcheck to verify RabbitMQ connectivity."""
2+
from __future__ import annotations
3+
4+
import os
5+
import sys
6+
7+
import pika
8+
9+
10+
def main() -> int:
11+
rabbit_url = os.getenv("RABBITMQ_URL", "amqp://ingest:ingest@rabbitmq:5672/")
12+
try:
13+
connection = pika.BlockingConnection(pika.URLParameters(rabbit_url))
14+
try:
15+
channel = connection.channel()
16+
channel.basic_qos(prefetch_count=1)
17+
finally:
18+
connection.close()
19+
except Exception as exc: # pragma: no cover - run-time diagnostic
20+
print(f"[healthcheck] RabbitMQ unavailable: {exc}", file=sys.stderr)
21+
return 1
22+
return 0
23+
24+
25+
if __name__ == "__main__":
26+
raise SystemExit(main())

0 commit comments

Comments
 (0)