feat: 完成redis的初始化动作
This commit is contained in:
+7
-2
@@ -11,6 +11,7 @@ from app.middlewares.app_middlewares import add_app_middlewares
|
||||
from app.utils.db_utils import check_database_connection
|
||||
from app.utils.milvus_utils import milvus_service
|
||||
from app.utils.postgres_checkpointer import check_postgres_connection, close_postgres_connection
|
||||
from app.utils.redis_utils import redis_utils
|
||||
|
||||
|
||||
def create_app():
|
||||
@@ -21,12 +22,16 @@ def create_app():
|
||||
asyncio.create_task(check_database_connection()),
|
||||
asyncio.create_task(check_postgres_connection()),
|
||||
asyncio.create_task(milvus_service.check_milvus_connection()),
|
||||
asyncio.create_task(redis_utils.check_redis_connection()),
|
||||
)
|
||||
async_engine = async_results[0]
|
||||
yield
|
||||
print("lifespan:销毁阶段")
|
||||
await async_engine.dispose()
|
||||
await close_postgres_connection()
|
||||
await asyncio.gather(
|
||||
async_engine.dispose(),
|
||||
close_postgres_connection(),
|
||||
redis_utils.close_redis_connection()
|
||||
)
|
||||
|
||||
app = FastAPI(
|
||||
docs_url=None, # 禁用默认 Swagger
|
||||
|
||||
Reference in New Issue
Block a user