Better restart/shutdown refresh page polling

This commit is contained in:
JonnyWong16 2017-12-09 22:32:39 -08:00
commit b76143116c

View file

@ -54,34 +54,31 @@
window.location.href = "${new_http_root}index"; window.location.href = "${new_http_root}index";
} }
// Redirect to home page if page is available. var online = true;
var checkOnline = setInterval(checkPageOffline, 1000);
function checkPageOffline() { (function poll() {
setTimeout(function () {
$.ajax({ $.ajax({
type: 'HEAD',
url: 'index', url: 'index',
timeout: 1000, type: 'HEAD',
success: function () {
if (!(online)){
reloadPage();
}
},
error: function () { error: function () {
% if signal != 'shutdown': online = false;
clearInterval(checkOnline); % if signal == 'shutdown':
setInterval(checkPageOnline, 1000);
% else:
reloadPage(); reloadPage();
% endif % endif
} },
complete: function () {
poll();
},
timeout: 1000
}); });
} }, 1000);
function checkPageOnline() { })();
$.ajax({
type: 'HEAD',
url: 'index',
timeout: 1000,
success: function () {
reloadPage();
}
});
}
</script> </script>
</%def> </%def>