feat: 改为安装包分发并使用动态端口

This commit is contained in:
2026-10-25 02:31:23 +08:00
parent 5ca491834e
commit f5779369a5
34 changed files with 392 additions and 49 deletions
+11 -1
View File
@@ -45,6 +45,16 @@ async def health() -> dict:
if __name__ == "__main__":
import os
import socket
import uvicorn
uvicorn.run("app.main:app", host="127.0.0.1", port=8765)
chosen = os.environ.get("NQI_PORT")
if chosen:
port = int(chosen)
else:
with socket.socket() as sock:
sock.bind(("127.0.0.1", 0))
port = sock.getsockname()[1]
uvicorn.run("app.main:app", host="127.0.0.1", port=port)