Fix reboot flow: add /api/ping, fix waitForServerReboot polling, fix security.js handler
Agent-Logs-Url: https://github.com/naturallaw777/staging_alpha/sessions/ee8673cf-ad65-4f65-b5c8-2f170e78022f Co-authored-by: naturallaw777 <99053422+naturallaw777@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c5bbb5220e
commit
7576c0fe85
@@ -161,6 +161,8 @@ function openSecurityModal() {
|
||||
rebootBtn.disabled = true;
|
||||
rebootBtn.textContent = "Rebooting\u2026";
|
||||
if ($rebootOverlay) $rebootOverlay.classList.add("visible");
|
||||
_rebootStartTime = Date.now();
|
||||
_serverWentDown = false;
|
||||
setTimeout(waitForServerReboot, REBOOT_INITIAL_DELAY);
|
||||
var rebootCtrl = new AbortController();
|
||||
setTimeout(function() { rebootCtrl.abort(); }, REBOOT_REQUEST_TIMEOUT);
|
||||
|
||||
@@ -185,21 +185,19 @@ function waitForServerReboot() {
|
||||
var controller = new AbortController();
|
||||
var timeoutId = setTimeout(function() { controller.abort(); }, REBOOT_FETCH_TIMEOUT);
|
||||
|
||||
fetch("/api/config", { cache: "no-store", signal: controller.signal, headers: { "Connection": "close" } })
|
||||
fetch("/api/ping", { cache: "no-store", signal: controller.signal, headers: { "Connection": "close" } })
|
||||
.then(function(res) {
|
||||
clearTimeout(timeoutId);
|
||||
if (res.ok && _serverWentDown) {
|
||||
// Server is back after having been down — reboot is complete
|
||||
if (_serverWentDown) {
|
||||
// Server is responding after having been down — reboot is complete.
|
||||
// Any response (even 401/500) means the server process is back.
|
||||
window.location.reload();
|
||||
} else if (res.ok && !_serverWentDown && (Date.now() - _rebootStartTime) < 90000) {
|
||||
} else if ((Date.now() - _rebootStartTime) < 90000) {
|
||||
// Server still responding but hasn't gone down yet — keep waiting
|
||||
setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL);
|
||||
} else if (res.ok) {
|
||||
} else {
|
||||
// Been over 90 seconds and server is responding — just reload
|
||||
window.location.reload();
|
||||
} else {
|
||||
_serverWentDown = true;
|
||||
setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL);
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
|
||||
Reference in New Issue
Block a user