Browse Source

Config restart-check faster because shutdown is now much faster

tags/3.3.0RC1
Safihre 4 years ago
parent
commit
994a7d044f
  1. 19
      interfaces/Config/templates/staticcfg/js/script.js

19
interfaces/Config/templates/staticcfg/js/script.js

@ -264,13 +264,13 @@ function do_restart() {
$.ajax({ url: '../../config/restart?apikey=' + sabSession, $.ajax({ url: '../../config/restart?apikey=' + sabSession,
complete: function() { complete: function() {
// Keep counter of failures // Keep counter of failures
var failureCounter = 0; var loopCounter = 0;
// Now we try until we can connect // Now we try until we can connect
var refreshInterval = setInterval(function() { setInterval(function() {
// We skip the first one loopCounter = loopCounter+1;
if(failureCounter == 0) { // We skip the first one so we give it time to shutdown
failureCounter = failureCounter+1; if(loopCounter < 2) {
return return
} }
$.ajax({ url: urlTotal, $.ajax({ url: urlTotal,
@ -279,17 +279,16 @@ function do_restart() {
location.href = urlTotal; location.href = urlTotal;
}, },
error: function(status, text) { error: function(status, text) {
failureCounter = failureCounter+1; // Too many failures and we give up
// Too many failuers and we give up if(loopCounter >= 10) {
if(failureCounter >= 6) {
// If the port has changed 'Access-Control-Allow-Origin' header will not allow // If the port has changed 'Access-Control-Allow-Origin' header will not allow
// us to check if the server is back up. So after 7 failures we redirect // us to check if the server is back up. So after 10 failures (20 sec) we redirect
// anyway in the hopes it works anyway.. // anyway in the hopes it works anyway..
location.href = urlTotal; location.href = urlTotal;
} }
} }
}) })
}, 4000) }, 2000)
// Exception if we go from HTTPS to HTTP // Exception if we go from HTTPS to HTTP
// (this is not allowed by browsers and all of the above will be ignored) // (this is not allowed by browsers and all of the above will be ignored)

Loading…
Cancel
Save