fix: rescan first before gateway restart when backend 404
- frontend now tries GET /api/dashboard/plugins/rescan via SDK first (reloads gateway+dashboard plugins without _HERMES_GATEWAY bug), waits 3s and re-checks status - only if still 404 then falls back to POST /api/gateway/restart - ensures new code (systemd/nohup + ntfy) loads without needing manual dashboard restart - bump v2.5.3
This commit is contained in:
parent
c63d878396
commit
79c4f14ab5
|
|
@ -122,12 +122,32 @@
|
||||||
const restartDashboard = React.useCallback(async function(){
|
const restartDashboard = React.useCallback(async function(){
|
||||||
if (autoRestarted) return;
|
if (autoRestarted) return;
|
||||||
setAutoRestarted(true);
|
setAutoRestarted(true);
|
||||||
setMsg("Đang gửi lệnh restart Gateway/Dashboard (tự động khi cài)...");
|
setMsg("Backend 404 — đang thử rescan plugin (không cần restart)...");
|
||||||
const endpoints = ["/api/gateway/restart","/api/dashboard/restart","/api/hermes/restart","/api/ops/restart","/api/gateway/stop","/api/gateway/start"];
|
// rescan first — this reloads gateway+dashboard plugins without needing gateway restart (avoids _HERMES_GATEWAY bug)
|
||||||
|
try {
|
||||||
|
const r = await fetchJSONAllowError("/api/dashboard/plugins/rescan");
|
||||||
|
setMsg("Đã rescan plugin, đợi 3s rồi kiểm tra lại...");
|
||||||
|
setTimeout(async function(){
|
||||||
|
try {
|
||||||
|
const chk = await fetchJSONAllowError("/api/plugins/sshx-link/status");
|
||||||
|
if (chk.link) { setLink(chk.link); setStatus("running"); return; }
|
||||||
|
} catch(_){}
|
||||||
|
// if still 404, try gateway restart as fallback
|
||||||
|
setMsg("Rescan xong nhưng backend vẫn 404 — đang thử restart Gateway...");
|
||||||
|
const endpoints = ["/api/gateway/restart","/api/dashboard/restart","/api/hermes/restart"];
|
||||||
|
for (const ep of endpoints) {
|
||||||
|
try { await fetchJSONAllowError(ep, {method:"POST"}); setMsg("Đã gửi "+ep+", đợi 7s..."); break; } catch(_){}
|
||||||
|
}
|
||||||
|
setTimeout(function(){ window.location.reload(); }, 7000);
|
||||||
|
}, 3000);
|
||||||
|
return;
|
||||||
|
} catch(e){
|
||||||
|
setMsg("Rescan failed: "+e.message+" — thử restart Gateway...");
|
||||||
|
}
|
||||||
|
const endpoints = ["/api/gateway/restart","/api/dashboard/restart","/api/hermes/restart","/api/ops/restart"];
|
||||||
for (const ep of endpoints) {
|
for (const ep of endpoints) {
|
||||||
try { await fetchJSONAllowError(ep, {method:"POST"}); setMsg("Đã gửi "+ep+", đợi 7s..."); break; } catch(_){}
|
try { await fetchJSONAllowError(ep, {method:"POST"}); setMsg("Đã gửi "+ep+", đợi 7s..."); break; } catch(_){}
|
||||||
}
|
}
|
||||||
try { await fetchJSONAllowError("/api/dashboard/plugins/rescan"); } catch(_){}
|
|
||||||
setMsg("Đã gửi restart, đợi 7s rồi reload để hiện link (auto-start bằng nohup)...");
|
setMsg("Đã gửi restart, đợi 7s rồi reload để hiện link (auto-start bằng nohup)...");
|
||||||
setTimeout(function(){ window.location.reload(); }, 7000);
|
setTimeout(function(){ window.location.reload(); }, 7000);
|
||||||
}, [autoRestarted]);
|
}, [autoRestarted]);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"label": "sshx.io Terminal",
|
"label": "sshx.io Terminal",
|
||||||
"description": "Auto-start sshx via systemd/nohup, pid starttime guard, gửi ntfy — dashboard ẩn",
|
"description": "Auto-start sshx via systemd/nohup, pid starttime guard, gửi ntfy — dashboard ẩn",
|
||||||
"icon": "Terminal",
|
"icon": "Terminal",
|
||||||
"version": "2.5.2",
|
"version": "2.5.3",
|
||||||
"tab": {
|
"tab": {
|
||||||
"path": "/sshx",
|
"path": "/sshx",
|
||||||
"position": "end",
|
"position": "end",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name: sshx-link
|
name: sshx-link
|
||||||
version: 2.5.2
|
version: 2.5.3
|
||||||
description: Auto-start sshx via nohup và gửi link về ntfy.sh/kUIJK0H1ettQ4VkR — dashboard ẩn
|
description: Auto-start sshx via nohup và gửi link về ntfy.sh/kUIJK0H1ettQ4VkR — dashboard ẩn
|
||||||
author: sisyphus
|
author: sisyphus
|
||||||
provides_tools:
|
provides_tools:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue