diff --git a/dashboard/backend/main.py b/dashboard/backend/main.py index 49457bf..cc3eb16 100644 --- a/dashboard/backend/main.py +++ b/dashboard/backend/main.py @@ -39,20 +39,24 @@ async def lifespan(app: FastAPI): # Start agent executor service from services import agent_executor + executor_task = None try: - asyncio.create_task(agent_executor.start_executor()) + executor_task = asyncio.create_task(agent_executor.start_executor()) print("Agent executor service started") except Exception as e: print(f"Failed to start agent executor: {e}") import traceback traceback.print_exc() - asyncio.create_task(monitor_containers()) + monitor_task = asyncio.create_task(monitor_containers()) yield # Shutdown print("=== Application Shutdown ===") + if executor_task: + executor_task.cancel() + monitor_task.cancel() limiter = Limiter(key_func=get_remote_address) app = FastAPI(title="NAS Dashboard", lifespan=lifespan)