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: