fix: store executor and monitor tasks to prevent garbage collection
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user