This commit is contained in:
eric
2026-03-29 04:12:59 -05:00
parent e20c1a0b0b
commit 3dc82e1158
2 changed files with 14 additions and 6 deletions

17
web.py
View File

@@ -342,12 +342,17 @@ async def lifespan(app: FastAPI):
except Exception:
# PM2/Shell 异常时不阻塞整站启动(否则反代持续 502
pass
try:
ok, msg = await asyncio.to_thread(ensure_scrcpy_jar, BASE_DIR)
if not ok:
print(f"[web] scrcpy-server: {msg}", file=sys.stderr)
except Exception as exc:
print(f"[web] scrcpy-server bootstrap: {exc}", file=sys.stderr)
# scrcpy-server 下载可走外网重试,勿阻塞启动;否则 systemd 默认 TimeoutStartSec≈90s 会杀进程,:8001 永不起
async def _bootstrap_scrcpy() -> None:
try:
ok, msg = await asyncio.to_thread(ensure_scrcpy_jar, BASE_DIR)
if not ok:
print(f"[web] scrcpy-server: {msg}", file=sys.stderr)
except Exception as exc:
print(f"[web] scrcpy-server bootstrap: {exc}", file=sys.stderr)
asyncio.create_task(_bootstrap_scrcpy())
yield