feat: 完成redis的初始化动作

This commit is contained in:
martsforever
2025-09-27 20:24:28 +08:00
parent 5eb8afcc43
commit c9c3ae91e1
8 changed files with 143 additions and 3 deletions
+7 -2
View File
@@ -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