2014-05-13 09:58:27 +00:00
|
|
|
if (sbHandleReverseProxy != "False" && sbHandleReverseProxy != 0)
|
|
|
|
// Don't add the port to the url if using reverse proxy
|
|
|
|
if (sbHttpsEnabled != "False" && sbHttpsEnabled != 0)
|
|
|
|
var sb_base_url = 'https://'+sbHost+sbRoot;
|
|
|
|
else
|
|
|
|
var sb_base_url = 'http://'+sbHost+sbRoot;
|
2014-03-10 05:18:05 +00:00
|
|
|
else
|
2014-05-13 09:58:27 +00:00
|
|
|
if (sbHttpsEnabled != "False" && sbHttpsEnabled != 0)
|
|
|
|
var sb_base_url = 'https://'+sbHost+':'+sbHttpPort+sbRoot;
|
|
|
|
else
|
|
|
|
var sb_base_url = 'http://'+sbHost+':'+sbHttpPort+sbRoot;
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
var base_url = window.location.protocol+'//'+window.location.host+sbRoot;
|
|
|
|
var is_alive_url = sbRoot+'/home/is_alive';
|
|
|
|
var timeout_id;
|
2014-06-23 15:18:01 +00:00
|
|
|
var restarted = '';
|
2014-03-10 05:18:05 +00:00
|
|
|
var num_restart_waits = 0;
|
|
|
|
|
2014-06-26 01:40:36 +00:00
|
|
|
function restartHandler() {
|
2014-03-10 05:18:05 +00:00
|
|
|
num_restart_waits += 1;
|
|
|
|
|
|
|
|
$('#shut_down_loading').hide();
|
|
|
|
$('#shut_down_success').show();
|
|
|
|
$('#restart_message').show();
|
|
|
|
is_alive_url = sb_base_url+'/home/is_alive';
|
|
|
|
|
2014-05-13 09:58:27 +00:00
|
|
|
// if https is enabled or you are currently on https and the port or protocol changed just wait 5 seconds then redirect.
|
2014-03-10 05:18:05 +00:00
|
|
|
// This is because the ajax will fail if the cert is untrusted or the the http ajax requst from https will fail because of mixed content error.
|
|
|
|
if ((sbHttpsEnabled != "False" && sbHttpsEnabled != 0) || window.location.protocol == "https:") {
|
|
|
|
if (base_url != sb_base_url) {
|
|
|
|
timeout_id = 1;
|
|
|
|
setTimeout(function(){
|
|
|
|
$('#restart_loading').hide();
|
|
|
|
$('#restart_success').show();
|
|
|
|
$('#refresh_message').show();
|
|
|
|
}, 3000);
|
2014-06-16 05:45:52 +00:00
|
|
|
setTimeout("window.location = sb_base_url+'/home/'", 5000);
|
2014-03-10 05:18:05 +00:00
|
|
|
}
|
2014-06-26 01:40:36 +00:00
|
|
|
} else {
|
|
|
|
timeout_id = 1;
|
|
|
|
setTimeout(function(){
|
|
|
|
$('#restart_loading').hide();
|
|
|
|
$('#restart_success').show();
|
|
|
|
$('#refresh_message').show();
|
|
|
|
}, 3000);
|
|
|
|
setTimeout("window.location = sb_base_url+'/home/'", 5000);
|
2014-03-10 05:18:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if it is taking forever just give up
|
|
|
|
if (num_restart_waits > 90) {
|
|
|
|
$('#restart_loading').hide();
|
|
|
|
$('#restart_failure').show();
|
|
|
|
$('#restart_fail_message').show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timeout_id == 0)
|
|
|
|
timeout_id = setTimeout('is_alive()', 1000);
|
2014-06-26 01:40:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function is_alive() {
|
|
|
|
timeout_id = 0;
|
|
|
|
|
|
|
|
$.get(is_alive_url, function(data) {
|
|
|
|
|
|
|
|
// if it's still initalizing then just wait and try again
|
|
|
|
if (data.msg == 'nope') {
|
|
|
|
$('#shut_down_loading').hide();
|
|
|
|
$('#shut_down_success').show();
|
|
|
|
$('#restart_message').show();
|
|
|
|
setTimeout('is_alive()', 1000);
|
|
|
|
} else if (data.restarted == 'True') {
|
|
|
|
restartHandler();
|
|
|
|
} else {
|
|
|
|
// if this is before we've even shut down then just try again later
|
|
|
|
if (restarted == '' || data.restarted == restarted) {
|
|
|
|
restarted = data.restarted;
|
|
|
|
setTimeout(is_alive, 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 'jsonp');
|
|
|
|
}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-06-26 01:40:36 +00:00
|
|
|
$(document).ready(function()
|
|
|
|
{
|
|
|
|
is_alive();
|
2014-03-10 05:18:05 +00:00
|
|
|
});
|