2014-05-13 05:58:27 -04: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 01:18:05 -04:00
|
|
|
else
|
2014-05-13 05:58:27 -04: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 01:18:05 -04:00
|
|
|
|
|
|
|
var base_url = window.location.protocol+'//'+window.location.host+sbRoot;
|
|
|
|
var is_alive_url = sbRoot+'/home/is_alive';
|
|
|
|
var timeout_id;
|
|
|
|
var current_pid = '';
|
|
|
|
var num_restart_waits = 0;
|
|
|
|
|
|
|
|
function is_alive() {
|
|
|
|
timeout_id = 0;
|
|
|
|
$.get(is_alive_url, function(data) {
|
2014-05-13 05:58:27 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
// 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 this is before we've even shut down then just try again later
|
|
|
|
if (current_pid == '' || data.msg == current_pid) {
|
|
|
|
current_pid = data.msg;
|
|
|
|
setTimeout(is_alive, 1000);
|
|
|
|
|
|
|
|
// if we're ready to go then redirect to new url
|
|
|
|
} else {
|
|
|
|
$('#restart_loading').hide();
|
|
|
|
$('#restart_success').show();
|
|
|
|
$('#refresh_message').show();
|
|
|
|
window.location = sb_base_url+'/home';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 'jsonp');
|
|
|
|
}
|
|
|
|
|
2014-05-13 05:58:27 -04:00
|
|
|
$(document).ready(function()
|
|
|
|
{
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
is_alive();
|
2014-05-13 05:58:27 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
$(document).ajaxError(function(e, jqxhr, settings, exception) {
|
|
|
|
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 05:58:27 -04: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 01:18:05 -04: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);
|
|
|
|
setTimeout("window.location = sb_base_url+'/home'", 5000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|