feat: 启动时检查数据库连接
This commit is contained in:
@@ -15,13 +15,16 @@ from app.controller.add_graph_proxy_route import add_graph_proxy_route
|
||||
from app.routes import routes
|
||||
from app.utils.get_local_ips import get_local_ips
|
||||
from app.utils.llm_utils import create_llm
|
||||
from app.utils.mysql_utils import check_database_connection
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
print(f"应用启动:{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
async_engine = await check_database_connection()
|
||||
yield
|
||||
print(f"应用销毁:{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
await async_engine.dispose()
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
|
||||
Reference in New Issue
Block a user