From ced87996f319b94cad6f632333e85b8581883547 Mon Sep 17 00:00:00 2001 From: MAHaines Date: Mon, 14 Jul 2025 00:30:34 -0500 Subject: [PATCH] Create Whisper service health check --- services/whisper-service/src/healthcheck.py | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 services/whisper-service/src/healthcheck.py diff --git a/services/whisper-service/src/healthcheck.py b/services/whisper-service/src/healthcheck.py new file mode 100644 index 0000000..e409a73 --- /dev/null +++ b/services/whisper-service/src/healthcheck.py @@ -0,0 +1,35 @@ +import os +import asyncio +import requests +import redis.asyncio as redis +import psycopg2 + +async def health_check(): + """Health check for Whisper service""" + try: + # Test API endpoint + response = requests.get("http://localhost:8000/health", timeout=10) + if response.status_code != 200: + raise Exception(f"API health check failed: {response.status_code}") + + # Test Redis connection + redis_client = redis.from_url(os.getenv('REDIS_URL', 'redis://redis:6379')) + await redis_client.ping() + await redis_client.close() + + # Test PostgreSQL connection + pg_conn = psycopg2.connect(os.getenv('POSTGRES_URL')) + cursor = pg_conn.cursor() + cursor.execute('SELECT 1') + cursor.close() + pg_conn.close() + + print("Health check passed") + exit(0) + + except Exception as e: + print(f"Health check failed: {e}") + exit(1) + +if __name__ == "__main__": + asyncio.run(health_check())