Add Audio Processor health check
This commit is contained in:
29
services/audio-processor/src/healthcheck.py
Normal file
29
services/audio-processor/src/healthcheck.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import asyncio
|
||||
import redis.asyncio as redis
|
||||
import psycopg2
|
||||
|
||||
async def health_check():
|
||||
"""Health check for audio processor service"""
|
||||
try:
|
||||
# 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())
|
Reference in New Issue
Block a user