V45.39: fix SERVER OFFLINE lau + UI load cham - engine ghi port file (engine_port.txt), UI bootstrap doc port engine cua chinh no (get_engine_port) + timeout/retry 60s, health poll self-heal reload, khong taskkill /IM daw_engine (giet engine instance khac), /api/v1/plugins/available chay scan trong threadpool (khong chan event loop -> /health het timeout)

This commit is contained in:
2026-09-01 16:45:06 +07:00
parent 1e0314249d
commit 2c4d6c358b
7 changed files with 2849 additions and 2756 deletions
+8
View File
@@ -194,6 +194,14 @@ def get_scanner():
@router.get("/available")
async def list_plugins(current_user: dict = Depends(get_current_user)):
# Scan VST/SF chạy subprocess đồng bộ (fx_vst_bridge --scan, timeout 300s/
# dir; Ozone treo tới 30s/module) — chạy trực tiếp trên event loop sẽ chặn
# /health và mọi request khác → UI báo SERVER: OFFLINE suốt thời gian scan.
# Chạy trong threadpool để event loop luôn phản hồi.
return await asyncio.to_thread(_list_plugins_impl)
def _list_plugins_impl():
d = _effective_dirs()
pm = PluginManager(vst_dir=d["vst_dir"], sf_dir=d["soundfont_dir"], upload_sf_dir=UPLOAD_SF_DIR, extra_vst_dirs=d["plugin_dirs"], user_dirs_override=d.get("plugin_dirs_user_set", False))
avail = pm.list_available()
+16 -3
View File
@@ -23741,15 +23741,28 @@ const App = () => {
return () => observer.disconnect();
}, [timelineWrapperNode]);
useEffect(() => {
let cancelled = false, busy = false, iv = null;
let cancelled = false, busy = false, iv = null, offlineCount = 0;
const check = () => {
if (busy || cancelled) return;
busy = true;
const ctl = new AbortController();
const t = setTimeout(() => ctl.abort(), 3000);
fetch(API_BASE_URL, { signal: ctl.signal })
.then(r => { if (!cancelled) setServerStatus(r.ok ? 'connected' : 'error'); })
.catch(() => { if (!cancelled) setServerStatus('offline'); })
.then(r => { if (!cancelled) { setServerStatus(r.ok ? 'connected' : 'error'); offlineCount = 0; } })
.catch(() => {
if (!cancelled) {
setServerStatus('offline');
// Self-heal: engine chết/mất kết nối liên tục (~9s) → reload trang
// để bootstrap chạy lại: ưu tiên port engine của chính app
// (engine_port.txt) + fallback quét 8000-8010. Trước đây kẹt
// OFFLINE vĩnh viễn khi engine bị instance khác giết port.
offlineCount++;
if (offlineCount >= 3) {
offlineCount = 0;
try { window.location.reload(); } catch (e) {}
}
}
})
.finally(() => { busy = false; clearTimeout(t); });
};
check();
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -51,7 +51,7 @@
<script src="/static/js/services/promptTemplateManager.js?v=202608290945"></script>
<script src="/static/js/services/undoRedoEngine.js?v=202608290945"></script>
<script src="/static/js/services/chordTheory.js?v=202608290945"></script>
<script src="/static/js/app.precompiled.js?v=202608311858" defer></script>
<script src="/static/js/app.precompiled.js?v=202609011700" defer></script>
<link rel="stylesheet" href="/static/css/styles.css?v=202608290945">
<style>
:root {