fix: store executor and monitor tasks to prevent garbage collection
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 2m39s
Run Tests / Backend Tests (push) Failing after 53s
Run Tests / Frontend Tests (push) Failing after 1m16s
Run Tests / Test Summary (push) Failing after 24s

This commit is contained in:
Gan, Jimmy
2026-04-02 08:49:12 +08:00
parent 949838c5f2
commit 7b466e3980
+6 -2
View File
@@ -39,20 +39,24 @@ async def lifespan(app: FastAPI):
# Start agent executor service # Start agent executor service
from services import agent_executor from services import agent_executor
executor_task = None
try: try:
asyncio.create_task(agent_executor.start_executor()) executor_task = asyncio.create_task(agent_executor.start_executor())
print("Agent executor service started") print("Agent executor service started")
except Exception as e: except Exception as e:
print(f"Failed to start agent executor: {e}") print(f"Failed to start agent executor: {e}")
import traceback import traceback
traceback.print_exc() traceback.print_exc()
asyncio.create_task(monitor_containers()) monitor_task = asyncio.create_task(monitor_containers())
yield yield
# Shutdown # Shutdown
print("=== Application Shutdown ===") print("=== Application Shutdown ===")
if executor_task:
executor_task.cancel()
monitor_task.cancel()
limiter = Limiter(key_func=get_remote_address) limiter = Limiter(key_func=get_remote_address)
app = FastAPI(title="NAS Dashboard", lifespan=lifespan) app = FastAPI(title="NAS Dashboard", lifespan=lifespan)