From 79c4f14ab5c4b71d2739747377f9b3cfbb46f703 Mon Sep 17 00:00:00 2001 From: 6zev Date: Thu, 3 Sep 2026 05:36:02 +0000 Subject: [PATCH] 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 --- dashboard/dist/index.js | 26 +++++++++++++++++++++++--- dashboard/manifest.json | 2 +- plugin.yaml | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/dashboard/dist/index.js b/dashboard/dist/index.js index 3527b5e..d5a8116 100644 --- a/dashboard/dist/index.js +++ b/dashboard/dist/index.js @@ -122,12 +122,32 @@ const restartDashboard = React.useCallback(async function(){ if (autoRestarted) return; setAutoRestarted(true); - setMsg("Đang gửi lệnh restart Gateway/Dashboard (tự động khi cài)..."); - const endpoints = ["/api/gateway/restart","/api/dashboard/restart","/api/hermes/restart","/api/ops/restart","/api/gateway/stop","/api/gateway/start"]; + setMsg("Backend 404 — đang thử rescan plugin (không cần restart)..."); + // 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) { 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)..."); setTimeout(function(){ window.location.reload(); }, 7000); }, [autoRestarted]); diff --git a/dashboard/manifest.json b/dashboard/manifest.json index e25a7c6..423984b 100644 --- a/dashboard/manifest.json +++ b/dashboard/manifest.json @@ -3,7 +3,7 @@ "label": "sshx.io Terminal", "description": "Auto-start sshx via systemd/nohup, pid starttime guard, gửi ntfy — dashboard ẩn", "icon": "Terminal", - "version": "2.5.2", + "version": "2.5.3", "tab": { "path": "/sshx", "position": "end", diff --git a/plugin.yaml b/plugin.yaml index df8e46f..152168e 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ 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 author: sisyphus provides_tools: