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)
+10 -2
View File
@@ -1,5 +1,13 @@
import os
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[3]
DATA_ROOT = REPO_ROOT / "data"
def _data_root() -> Path:
override = os.environ.get("NQI_DATA_DIR")
if override:
return Path(override)
return Path(__file__).resolve().parents[3] / "data"
DATA_ROOT = _data_root()
DOWNLOAD_DIR = DATA_ROOT / "jobs"