mirror of
https://github.com/FuzzingLabs/fuzzforge_ai.git
synced 2026-02-12 23:52:47 +00:00
Add RabbitMQ healthcheck
This commit is contained in:
@@ -599,6 +599,12 @@ services:
|
||||
LOG_LEVEL: INFO
|
||||
networks:
|
||||
- fuzzforge-network
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "healthcheck.py"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
# ============================================================================
|
||||
|
||||
@@ -6,6 +6,6 @@ WORKDIR /app
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY app.py ./
|
||||
COPY app.py healthcheck.py ./
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
|
||||
26
services/ingestion_dispatcher/healthcheck.py
Normal file
26
services/ingestion_dispatcher/healthcheck.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Simple healthcheck to verify RabbitMQ connectivity."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pika
|
||||
|
||||
|
||||
def main() -> int:
|
||||
rabbit_url = os.getenv("RABBITMQ_URL", "amqp://ingest:ingest@rabbitmq:5672/")
|
||||
try:
|
||||
connection = pika.BlockingConnection(pika.URLParameters(rabbit_url))
|
||||
try:
|
||||
channel = connection.channel()
|
||||
channel.basic_qos(prefetch_count=1)
|
||||
finally:
|
||||
connection.close()
|
||||
except Exception as exc: # pragma: no cover - run-time diagnostic
|
||||
print(f"[healthcheck] RabbitMQ unavailable: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user