19 lines
392 B
Python
19 lines
392 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from server.services import tasker
|
|
from src.agents.common.mcp import init_mcp_servers
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""FastAPI lifespan事件管理器"""
|
|
# 初始化 MCP 服务器配置
|
|
await init_mcp_servers()
|
|
|
|
await tasker.start()
|
|
yield
|
|
await tasker.shutdown()
|
|
|