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']
pidfile = os.path.normcase(os.path.join(os.path.dirname(__file__), 'bazarr.pid'))
if os.path.exists(pidfile):
logging.error("Bazarr already running, please stop it first.")
ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT)
try:
file = open(pidfile,'w')
except:
logging.error("Error trying to write pid file.")
else:
ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT)
try:
file = open(pidfile,'w')
except:
logging.error("Error trying to write pid file.")
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)
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):

View File

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

View File

@ -208,7 +208,7 @@
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');
})
@ -217,7 +217,7 @@
url: "{{base_url}}shutdown",
async: false
})
.fail(function(){
.always(function(){
document.open();
document.write('Bazarr has shutdown.');
document.close();
@ -227,12 +227,19 @@
$('#restart').click(function(){
$.ajax({
url: "{{base_url}}restart",
async: false
async: true
})
.done(function(){
document.open();
document.write('Bazarr is restarting. Please reload page manually until it come back (should be less than 30 seconds).');
document.close();
setTimeout(function(){ setInterval(ping, 2000); },8000);
});
})
function ping() {
$.ajax({
url: window.location.href,
success: function(result) {
window.location.reload();
}
});
}
</script>