Auto reload after restart

This commit is contained in:
morpheus65535 2018-10-10 07:15:06 -04:00
parent 56226f941d
commit 1cccd810ae
3 changed files with 24 additions and 20 deletions

View File

@ -30,20 +30,17 @@ def start_bazarr():
script = [sys.executable, os.path.normcase(os.path.join(os.path.dirname(__file__), 'bazarr/main.py'))] + globals()['arguments'] script = [sys.executable, os.path.normcase(os.path.join(os.path.dirname(__file__), 'bazarr/main.py'))] + globals()['arguments']
pidfile = os.path.normcase(os.path.join(os.path.dirname(__file__), 'bazarr.pid')) pidfile = os.path.normcase(os.path.join(os.path.dirname(__file__), 'bazarr.pid'))
if os.path.exists(pidfile): ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT)
logging.error("Bazarr already running, please stop it first.") try:
file = open(pidfile,'w')
except:
logging.error("Error trying to write pid file.")
else: else:
ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT) file.write(str(ep.pid))
try: file.close()
file = open(pidfile,'w') logging.info("Bazarr starting with process id: " + str(ep.pid) + "...")
except: for line in iter(ep.stdout.readline, ''):
logging.error("Error trying to write pid file.") sys.stdout.write(line)
else:
file.write(str(ep.pid))
file.close()
logging.info("Bazarr starting with process id: " + str(ep.pid) + "...")
for line in iter(ep.stdout.readline, ''):
sys.stdout.write(line)
def shutdown_bazarr(restarting): def shutdown_bazarr(restarting):

View File

@ -1,4 +1,4 @@
bazarr_version = '0.6.6' bazarr_version = '0.6.7'
import gc import gc
gc.enable() gc.enable()

View File

@ -208,7 +208,7 @@
window.location = '{{base_url}}execute/' + $(this).data("taskid"); window.location = '{{base_url}}execute/' + $(this).data("taskid");
}) })
$('a:not(.tabs), button:not(.cancel, #download_log)').click(function(){ $('a:not(.tabs), button:not(.cancel, #download_log), #restart').click(function(){
$('#loader').addClass('active'); $('#loader').addClass('active');
}) })
@ -217,7 +217,7 @@
url: "{{base_url}}shutdown", url: "{{base_url}}shutdown",
async: false async: false
}) })
.fail(function(){ .always(function(){
document.open(); document.open();
document.write('Bazarr has shutdown.'); document.write('Bazarr has shutdown.');
document.close(); document.close();
@ -227,12 +227,19 @@
$('#restart').click(function(){ $('#restart').click(function(){
$.ajax({ $.ajax({
url: "{{base_url}}restart", url: "{{base_url}}restart",
async: false async: true
}) })
.done(function(){ .done(function(){
document.open(); setTimeout(function(){ setInterval(ping, 2000); },8000);
document.write('Bazarr is restarting. Please reload page manually until it come back (should be less than 30 seconds).');
document.close();
}); });
}) })
function ping() {
$.ajax({
url: window.location.href,
success: function(result) {
window.location.reload();
}
});
}
</script> </script>