针对微信小程序的后台经过5天测试,具备一定的稳定性,提交版本用于保存
This commit is contained in:
@@ -9,10 +9,18 @@ import json
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
import uvicorn
|
||||
|
||||
# 加载 .env 文件中的环境变量
|
||||
load_dotenv() # 默认加载项目根目录的 .env 文件
|
||||
|
||||
from app.asr_service import asr_router
|
||||
from app.monitor_service import monitor_router
|
||||
from app.tts_service import tts_router,tts_lifespan
|
||||
from app.login_service import login_router
|
||||
from app.chat_service import chat_router
|
||||
from app.payment_service import payment_router
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""生命周期管理"""
|
||||
@@ -20,21 +28,17 @@ async def lifespan(app: FastAPI):
|
||||
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
print(" ASR & Monitor Service Start")
|
||||
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
# 启动TTS路由器的生命周期
|
||||
tts_lifespan_ctx = tts_lifespan(app)
|
||||
await tts_lifespan_ctx.__aenter__()
|
||||
yield
|
||||
# 关闭TTS路由器的生命周期
|
||||
await tts_lifespan_ctx.__aexit__(None, None, None)
|
||||
# 服务停止清理
|
||||
print("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
print(" Service Stopped Cleanly")
|
||||
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
|
||||
# 加载 .env 文件中的环境变量
|
||||
load_dotenv() # 默认加载项目根目录的 .env 文件
|
||||
|
||||
from app.asr_service import asr_router
|
||||
from app.monitor_service import monitor_router
|
||||
from app.tts_service import tts_router
|
||||
from app.login_service import login_router
|
||||
from app.chat_service import chat_router
|
||||
from app.payment_service import payment_router
|
||||
|
||||
# 创建应用实例
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
|
||||
Reference in New Issue
Block a user