Merge pull request #911 from JackDandy/feature/FixRestart

Feature/fix restart
This commit is contained in:
JackDandy 2017-02-09 19:33:09 +00:00 committed by GitHub
commit c8ea3719b4
2 changed files with 36 additions and 23 deletions

View file

@ -42,6 +42,7 @@
* Update tablesorter 2.17.7 to 2.28.5
* Update jQuery 1.8.3 to 2.2.4
* Add one time run to start up that deletes troublemaking compiled files
* Fix reload of homepage after restart in some browsers
[develop changelog]

View file

@ -15,29 +15,38 @@ $.SickGear.numRestartWaits = 0;
function is_alive() {
timeoutId = 0;
$.get(isAliveUrl, function(data) {
var resp = data.msg.toString();
if ('nope' == resp) {
// if initialising then just wait and try again
//noinspection JSUnusedLocalSymbols
$.ajax({
'url': isAliveUrl,
'type': 'GET',
'dataType': 'jsonp',
'success': function(data) {
var resp = data.msg.toString();
if ('nope' == resp) {
// if initialising then just wait and try again
$('#shut_down_message').find('.spinner,.hide-yes').removeClass();
$('#restart_message').removeClass();
$('#shut_down_message').find('.spinner,.hide-yes').removeClass();
$('#restart_message').removeClass();
setTimeout(is_alive, 100);
} else if (/undefined/i.test($.SickGear.PID) || $.SickGear.PID == resp) {
// if this is before we've even shut down then just try again later
setTimeout(is_alive, 100);
} else {
// if we're ready to go then redirect to new url
$('#restart_message').find('.spinner,.hide-yes').removeClass();
$('#refresh_message').removeClass();
window.location = baseUrl + '/home/';
}
},
'error': function(XMLHttpRequest, textStatus, errorThrown) {
setTimeout(is_alive, 100);
} else if (/undefined/i.test($.SickGear.PID) || $.SickGear.PID == resp) {
// if this is before we've even shut down then just try again later
setTimeout(is_alive, 100);
} else {
// if we're ready to go then redirect to new url
$('#restart_message').find('.spinner,.hide-yes').removeClass();
$('#refresh_message').removeClass();
window.location = baseUrl + '/home/';
}
}, 'jsonp');
});
}
$(document).ready(function() {
@ -49,11 +58,14 @@ $(document).ready(function() {
$.SickGear.numRestartWaits += 1;
$('#shut_down_message').find('.spinner,.hide-yes').removeClass();
$('#restart_message').removeClass();
var restart$ = $('#restart_message');
restart$.removeClass();
isAliveUrl = baseUrl + '/home/is_alive/';
// if https is enabled or you are currently on https and the port or protocol changed just wait 5 seconds then redirect.
// This is because the ajax will fail if the cert is untrusted or the the http ajax request from https will fail because of mixed content error.
// If using https and the port or protocol changed, then wait 5 seconds before redirect because ajax calls will
// fail with untrusted certs or when a http ajax request is made from https with a mixed content error.
if ($.SickGear.UseHttps || 'https:' == window.location.protocol) {
if (browserUrl != baseUrl) {
@ -71,7 +83,7 @@ $(document).ready(function() {
// if it is taking forever just give up
if (90 < $.SickGear.numRestartWaits) {
$('#restart_message').find('.spinner,.yes,.hide-no').removeClass();
restart$.find('.spinner,.yes,.hide-no').removeClass();
$('#restart_fail_message').removeClass();
return;
}