Spaces:
Paused
Paused
File size: 1,486 Bytes
4f625a6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | """
Worker health check script for Temporal workers.
This performs connectivity checks for Redis and Temporal Cloud.
"""
import dotenv
dotenv.load_dotenv()
from core.utils.logger import logger
from core.services import redis
from core.temporal.client import get_temporal_client
import asyncio
from core.utils.retry import retry
async def main():
"""
Health check that verifies:
1. Redis connection is working
2. Temporal Cloud connection is working
"""
try:
# Initialize Redis connection
await retry(lambda: redis.initialize_async())
# Simple ping to verify Redis connection
client = await redis.get_client()
pong = await client.ping()
if not pong:
logger.critical("Health check failed: Redis ping returned False")
exit(1)
# Verify Temporal Cloud connection
try:
temporal_client = await get_temporal_client()
# Connection successful if no exception raised
logger.info("Health check passed: Redis and Temporal Cloud connectivity OK")
except Exception as temporal_err:
logger.critical(f"Health check failed: Temporal Cloud connection error: {temporal_err}")
exit(1)
await redis.close()
exit(0)
except Exception as e:
logger.critical(f"Health check failed: {e}")
exit(1)
if __name__ == "__main__":
asyncio.run(main())
|