update
This commit is contained in:
parent
1b5b13b4ad
commit
946f1419f1
@ -5,16 +5,29 @@ from fastapi import FastAPI
|
|||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
|
from contextlib import asynccontextmanager
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
from app.utils.logger import logger
|
from app.utils.logger import logger
|
||||||
from app.api import chat, stock, skills, llm, auth, admin
|
from app.api import chat, stock, skills, llm, auth, admin
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
@asynccontextmanager
|
||||||
|
async def lifespan(app: FastAPI):
|
||||||
|
"""应用生命周期管理"""
|
||||||
|
# 启动时执行
|
||||||
|
logger.info("应用启动")
|
||||||
|
yield
|
||||||
|
# 关闭时执行
|
||||||
|
logger.info("应用关闭")
|
||||||
|
|
||||||
|
|
||||||
# 创建FastAPI应用
|
# 创建FastAPI应用
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="A股AI分析Agent系统",
|
title="A股AI分析Agent系统",
|
||||||
description="基于AI Agent的股票智能分析系统",
|
description="基于AI Agent的股票智能分析系统",
|
||||||
version="1.0.0"
|
version="1.0.0",
|
||||||
|
lifespan=lifespan
|
||||||
)
|
)
|
||||||
|
|
||||||
# 配置CORS
|
# 配置CORS
|
||||||
@ -59,16 +72,6 @@ async def health_check():
|
|||||||
"""健康检查"""
|
"""健康检查"""
|
||||||
return {"status": "healthy"}
|
return {"status": "healthy"}
|
||||||
|
|
||||||
@app.on_event("startup")
|
|
||||||
async def startup_event():
|
|
||||||
"""启动事件"""
|
|
||||||
logger.info("应用启动")
|
|
||||||
|
|
||||||
@app.on_event("shutdown")
|
|
||||||
async def shutdown_event():
|
|
||||||
"""关闭事件"""
|
|
||||||
logger.info("应用关闭")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import uvicorn
|
import uvicorn
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user