fix: 更新main.py逻辑
This commit is contained in:
@@ -5,6 +5,10 @@ from fastapi import FastAPI
|
||||
|
||||
from api.router import api_router
|
||||
from config import database
|
||||
from service.customer_agent.bootstrap import (
|
||||
build_default_knowledge_upload_service,
|
||||
build_default_runtime,
|
||||
)
|
||||
from utils.exceptions import register_exception_handlers
|
||||
from utils.logger import setup_logging
|
||||
from utils.request_id import RequestIdMiddleware
|
||||
@@ -13,6 +17,8 @@ from utils.request_id import RequestIdMiddleware
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
setup_logging() # 幂等:分级日志 + trace_id + 脱敏
|
||||
app.state.customer_agent_runtime = build_default_runtime()
|
||||
app.state.knowledge_upload_service = build_default_knowledge_upload_service()
|
||||
# 四库会话懒创建:启动不连接任何库,首次访问才建,可手动预热:
|
||||
# asyncio.run(database.init_db())
|
||||
yield
|
||||
@@ -28,4 +34,8 @@ app.include_router(api_router)
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "智能公募基金系统 API", "docs": "/docs"}
|
||||
return {"message": "智能公募基金系统 API", "docs": "/docs"}
|
||||
|
||||
if __name__ == '__main__':
|
||||
import uvicorn
|
||||
uvicorn.run('main:app', host="127.0.0.1", port=8000)
|
||||
|
||||
Reference in New Issue
Block a user