This commit is contained in:
熊潇 2025-05-03 01:18:29 +08:00
parent 4201d9c65a
commit 9cacdc1532
2 changed files with 3 additions and 2 deletions

4
app.py
View File

@ -149,13 +149,13 @@ async def get_a1(a1: Optional[str] = None):
# 在应用启动时初始化 Playwright # 在应用启动时初始化 Playwright
@app.on_event("startup") @app.lifespan("startup")
async def startup_event(): async def startup_event():
await initialize_playwright() await initialize_playwright()
# 在应用关闭时清理资源 # 在应用关闭时清理资源
@app.on_event("shutdown") @app.lifespan("shutdown")
async def shutdown_event(): async def shutdown_event():
global playwright_instance, browser_context, context_page global playwright_instance, browser_context, context_page
if context_page: if context_page:

View File

@ -4,6 +4,7 @@ module.exports = {
apps: [ apps: [
{ {
name: 'xhs-api-server', name: 'xhs-api-server',
script: 'app.py', // 替换为您的Python脚本路径
interpreter: 'python', // 替换为您的Python解释器路径 interpreter: 'python', // 替换为您的Python解释器路径
args: ['-m uvicorn app:app --host 0.0.0.0 --port', PORT], // 传递端口参数 args: ['-m uvicorn app:app --host 0.0.0.0 --port', PORT], // 传递端口参数
}, },