Fix issues

This commit is contained in:
Urtzi Alfaro
2025-10-01 14:39:10 +02:00
parent 6fa655275f
commit 36b44c41f1
5 changed files with 229 additions and 324 deletions

View File

@@ -85,34 +85,34 @@ class NotificationService(StandardFastAPIService):
}
# Define custom health checks for notification service components
async def check_email_service():
"""Check email service health - service is ready even if credentials are invalid"""
try:
if not self.email_service:
return False
# Service is considered healthy if it's initialized, even if credentials fail
# This allows the pod to be ready while external services may have config issues
await self.email_service.health_check()
return True
except Exception as e:
#async def check_email_service():
# """Check email service health - service is ready even if credentials are invalid"""
# try:
# if not self.email_service:
# return False
# # Service is considered healthy if it's initialized, even if credentials fail
# # This allows the pod to be ready while external services may have config issues
# await self.email_service.health_check()
# return True
# except Exception as e:
# Log but don't fail readiness - email service config issues shouldn't block the pod
self.logger.error("Email service health check failed", error=str(e))
# self.logger.error("Email service health check failed", error=str(e))
# Return True to indicate service is ready (initialized) even if credentials are wrong
return True
# return True
async def check_whatsapp_service():
"""Check WhatsApp service health - service is ready even if credentials are invalid"""
try:
if not self.whatsapp_service:
return False
#async def check_whatsapp_service():
# """Check WhatsApp service health - service is ready even if credentials are invalid"""
# try:
# if not self.whatsapp_service:
# return False
# Service is considered healthy if it's initialized, even if credentials fail
await self.whatsapp_service.health_check()
return True
except Exception as e:
# await self.whatsapp_service.health_check()
# return True
# except Exception as e:
# Log but don't fail readiness - WhatsApp config issues shouldn't block the pod
self.logger.error("WhatsApp service health check failed", error=str(e))
# self.logger.error("WhatsApp service health check failed", error=str(e))
# Return True to indicate service is ready (initialized) even if credentials are wrong
return True
# return True
async def check_sse_service():
"""Check SSE service health"""
@@ -125,14 +125,14 @@ class NotificationService(StandardFastAPIService):
self.logger.error("SSE service health check failed", error=str(e))
return False
async def check_messaging():
"""Check messaging service health"""
try:
from app.services.messaging import notification_publisher
return bool(notification_publisher and notification_publisher.connected)
except Exception as e:
self.logger.error("Messaging health check failed", error=str(e))
return False
#async def check_messaging():
# """Check messaging service health"""
# try:
# from app.services.messaging import notification_publisher
# return bool(notification_publisher and notification_publisher.connected)
# except Exception as e:
# self.logger.error("Messaging health check failed", error=str(e))
# return False
super().__init__(
service_name="notification-service",
@@ -145,10 +145,10 @@ class NotificationService(StandardFastAPIService):
database_manager=database_manager,
expected_tables=notification_expected_tables,
custom_health_checks={
"email_service": check_email_service,
"whatsapp_service": check_whatsapp_service,
# "email_service": check_email_service,
# "whatsapp_service": check_whatsapp_service,
"sse_service": check_sse_service,
"messaging": check_messaging
# "messaging": check_messaging
},
enable_messaging=True,
custom_metrics=notification_custom_metrics