FIX: liên tục mở tab browser trên exe

This commit is contained in:
2026-08-08 10:25:54 +07:00
parent 19d9bf3c9e
commit 3fc2087ee1
4 changed files with 27 additions and 12 deletions
+3 -10
View File
@@ -1,20 +1,13 @@
"""Entry point cho daw_engine.exe (PyInstaller — spec desktop 2026-08-08).
Chạy FastAPI backend trên 127.0.0.1:8000 (Dual-Process Desktop Architecture)."""
Chạy FastAPI backend trên 127.0.0.1:8000 (Dual-Process Desktop Architecture).
KHÔNG tự mở browser — Tauri shell (window url=localhost:8000) đảm nhiệm;
mở browser thủ công khi chạy standalone (bug 09:30: exe mở tab liên tục)."""
import os
import sys
import threading
import webbrowser
os.environ.setdefault("SFDATA_DIR", os.path.join(os.path.expanduser("~"), "SonicForgeDAW"))
import uvicorn # noqa: E402
def _open_browser():
webbrowser.open("http://127.0.0.1:8000")
if __name__ == "__main__":
# Mở browser sau khi server sẵn sàng (console=False — chạy ẩn)
threading.Timer(2.0, _open_browser).start()
uvicorn.run("app.main:app", host="127.0.0.1", port=8000, log_level="warning")