mirror of
https://github.com/FuzzingLabs/fuzzforge_ai.git
synced 2026-07-21 05:40:50 +02:00
Add RabbitMQ healthcheck
This commit is contained in:
@@ -599,6 +599,12 @@ services:
|
|||||||
LOG_LEVEL: INFO
|
LOG_LEVEL: INFO
|
||||||
networks:
|
networks:
|
||||||
- fuzzforge-network
|
- fuzzforge-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "python", "healthcheck.py"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
start_period: 10s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ WORKDIR /app
|
|||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY app.py ./
|
COPY app.py healthcheck.py ./
|
||||||
|
|
||||||
CMD ["python", "app.py"]
|
CMD ["python", "app.py"]
|
||||||
|
|||||||
@@ -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