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
+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