V45.39b: engine_port.txt ghi port+engine_exe_path, get_engine_port doi chieu path engine cua chinh app (2 instance khong doc lan port cua nhau)

This commit is contained in:
2026-09-01 17:02:23 +07:00
parent 2c4d6c358b
commit 67b8658015
2 changed files with 42 additions and 9 deletions
+3 -1
View File
@@ -120,10 +120,12 @@ def main():
# engine_port.txt (qua lệnh get_engine_port) để kết nối ĐÚNG engine của
# chính nó thay vì quét port — quét 8000-8010 có thể dính engine của
# instance khác (2 app chạy cùng lúc) → UI mất server khi instance đó tắt.
# Format "port\nengine_exe_path": Tauri đối chiếu path engine với candidate
# của CHÍNH nó → 2 app chạy song song mỗi cái lấy đúng port của mình.
try:
port_file = os.path.join(os.path.dirname(log_dir), "engine_port.txt")
with open(port_file, "w", encoding="utf-8") as f:
f.write(str(port))
f.write("%d\n%s" % (port, sys.executable))
except OSError:
pass