diff --git a/backend/app.py b/backend/app.py index 8ab9db0..16462c7 100644 --- a/backend/app.py +++ b/backend/app.py @@ -51,6 +51,14 @@ async def lifespan(app: FastAPI): except Exception as e: logger.error(f"Failed to ensure owner verification: {e}") + # Start the messaging cleanup task + try: + from routes.messaging import messagingManager + messagingManager.start_cleanup_task() + logger.info("Messaging cleanup task started") + except Exception as e: + logger.error(f"Failed to start messaging cleanup task: {e}") + yield # Shutdown (if needed in the future) diff --git a/backend/routes/messaging.py b/backend/routes/messaging.py index b7072c0..208af07 100644 --- a/backend/routes/messaging.py +++ b/backend/routes/messaging.py @@ -1344,8 +1344,6 @@ class MessaggingSocketManager: self._cleanup_task = asyncio.create_task(self.cleanup_stale_typing_indicators()) messagingManager = MessaggingSocketManager() -# Start the cleanup task -messagingManager.start_cleanup_task() @router.websocket("/chat/ws") async def chat_websocket(