fix: auto-start on install like ntfy version - dashboard auto-calls /start and auto-restart on 404
- frontend now auto-calls /start (nohup with fallback) 1.5s after detecting stopped, and auto-restarts dashboard 1.5s after detecting 404 (tries /api/gateway/restart, /api/dashboard/restart, etc.) - keeps passive link display but restores auto behavior like ntfy version: cài vô là tự chạy nohup & tạo link, hiện ra dashboard - bump v2.3.3
This commit is contained in:
parent
77514c9470
commit
d956b94826
|
|
@ -28,6 +28,7 @@
|
|||
const [status, setStatus] = React.useState("idle");
|
||||
const [msg, setMsg] = React.useState(null);
|
||||
const [triedAuto, setTriedAuto] = React.useState(false);
|
||||
const [autoRestarted, setAutoRestarted] = React.useState(false);
|
||||
|
||||
const check = React.useCallback(async function(){
|
||||
try {
|
||||
|
|
@ -69,12 +70,25 @@
|
|||
}, [status, triedAuto, doStart]);
|
||||
|
||||
const restartDashboard = React.useCallback(async function(){
|
||||
setMsg("Đang gửi lệnh restart Gateway/Dashboard...");
|
||||
try { await fetchJSONAllowError("/api/gateway/restart", {method:"POST"}); } catch(_){}
|
||||
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"];
|
||||
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...");
|
||||
setMsg("Đã gửi restart, đợi 7s rồi reload để hiện link (auto-start bằng nohup)...");
|
||||
setTimeout(function(){ window.location.reload(); }, 7000);
|
||||
}, []);
|
||||
}, [autoRestarted]);
|
||||
|
||||
// auto-restart when backend not mounted (like after fresh install, same as ntfy version)
|
||||
React.useEffect(function(){
|
||||
if (status === "needs_restart" && !autoRestarted) {
|
||||
const t = setTimeout(restartDashboard, 1500);
|
||||
return function(){ clearTimeout(t); };
|
||||
}
|
||||
}, [status, autoRestarted, restartDashboard]);
|
||||
|
||||
if (status === "needs_restart") {
|
||||
return React.createElement(Card, null,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"label": "sshx.io Terminal",
|
||||
"description": "Chỉ hiện link hiện tại — auto-start nohup (fallback), tự gọi /start nếu chưa có link",
|
||||
"icon": "Terminal",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"tab": {
|
||||
"path": "/sshx",
|
||||
"position": "end"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name: sshx-link
|
||||
version: 2.3.2
|
||||
version: 2.3.3
|
||||
description: Tạo shell ở sshx.io và trả link chia sẻ — auto arch detection, không cần restart dashboard
|
||||
author: sisyphus
|
||||
provides_tools:
|
||||
|
|
|
|||
Loading…
Reference in New Issue