From 5d6abb0aa28f778d2179788ad8717b51f9283016 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 26 Sep 2025 10:07:07 +0800 Subject: [PATCH] fix: remove problematic ModuleLogger dependencies from startup events - Remove ModuleLogger dependencies from notification and payment services startup - Fix startup blocking issues caused by circular database dependencies - Simplify freeleaps_app.py startup flows for both services - Service startup now completes without database connection dependency --- .../notification/webapi/bootstrap/freeleaps_app.py | 14 +++++--------- apps/payment/webapi/bootstrap/application.py | 1 - apps/payment/webapi/bootstrap/freeleaps_app.py | 12 ------------ 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/apps/notification/webapi/bootstrap/freeleaps_app.py b/apps/notification/webapi/bootstrap/freeleaps_app.py index 02488fa..bc6b03b 100644 --- a/apps/notification/webapi/bootstrap/freeleaps_app.py +++ b/apps/notification/webapi/bootstrap/freeleaps_app.py @@ -3,8 +3,6 @@ from backend.infra.rabbitmq.async_subscriber import AsyncMQSubscriber from backend.models.constants import NotificationChannel from webapi.utils.email_consumer import EmailMQConsumer from webapi.utils.sms_consumer import SmsMQConsumer -from common.log.module_logger import ModuleLogger -from common.config.app_settings import app_settings class FreeleapsApp(FastAPI): @@ -24,15 +22,13 @@ class FreeleapsApp(FastAPI): async def start_consumers(): print("starting up!") - # Add startup logging - module_logger = ModuleLogger(sender_id="ApplicationBootstrap") - await module_logger.log_info( - text=f"Notification service started successfully in {app_settings.APP_ENV} environment", - data={"app_name": app_settings.APP_NAME, "environment": app_settings.APP_ENV} - ) - + # Consumer registration first await self.sms_handler.register_consumer() await self.email_handler.register_consumer() + + # Note: If we want startup logging for audit purposes, + # it should be done AFTER all critical startup is complete + # and database is ready. Currently keeping minimal startup. @self.on_event("shutdown") async def stop_consumers(): diff --git a/apps/payment/webapi/bootstrap/application.py b/apps/payment/webapi/bootstrap/application.py index b287a94..2c87d5c 100644 --- a/apps/payment/webapi/bootstrap/application.py +++ b/apps/payment/webapi/bootstrap/application.py @@ -12,7 +12,6 @@ from webapi.providers import probes from webapi.providers import exception_handler from .freeleaps_app import FreeleapsApp from common.config.app_settings import app_settings -from common.log.module_logger import ModuleLogger def create_app() -> FastAPI: logging.info("App initializing") diff --git a/apps/payment/webapi/bootstrap/freeleaps_app.py b/apps/payment/webapi/bootstrap/freeleaps_app.py index cbedece..496633a 100644 --- a/apps/payment/webapi/bootstrap/freeleaps_app.py +++ b/apps/payment/webapi/bootstrap/freeleaps_app.py @@ -1,18 +1,6 @@ from fastapi import FastAPI -from common.log.module_logger import ModuleLogger -from common.config.app_settings import app_settings class FreeleapsApp(FastAPI): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.register_startup_event() - - def register_startup_event(self): - @self.on_event("startup") - async def startup_logging(): - module_logger = ModuleLogger(sender_id="ApplicationBootstrap") - await module_logger.log_info( - text=f"Payment service started successfully in {app_settings.APP_ENV} environment", - data={"app_name": app_settings.APP_NAME, "environment": app_settings.APP_ENV} - )