mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-16 14:25:02 -05:00
Updates/Restarts now use the same process instead of spawning a new one so the PID remains the same.
Fixed issue for restarts/updates on windows.
This commit is contained in:
parent
3c370fc5c9
commit
386355e130
18
SickBeard.py
18
SickBeard.py
@ -53,6 +53,7 @@ import threading
|
|||||||
import signal
|
import signal
|
||||||
import traceback
|
import traceback
|
||||||
import getopt
|
import getopt
|
||||||
|
import time
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
@ -380,6 +381,9 @@ def main():
|
|||||||
loadShowsFromDB()
|
loadShowsFromDB()
|
||||||
|
|
||||||
def startup():
|
def startup():
|
||||||
|
if sickbeard.restarted:
|
||||||
|
sickbeard.restarted = False
|
||||||
|
|
||||||
# Fire up all our threads
|
# Fire up all our threads
|
||||||
sickbeard.start()
|
sickbeard.start()
|
||||||
|
|
||||||
@ -408,4 +412,16 @@ def main():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if sys.hexversion >= 0x020600F0:
|
if sys.hexversion >= 0x020600F0:
|
||||||
freeze_support()
|
freeze_support()
|
||||||
main()
|
|
||||||
|
while(True):
|
||||||
|
main()
|
||||||
|
|
||||||
|
# check if restart was requested
|
||||||
|
if not sickbeard.restarted:
|
||||||
|
if sickbeard.CREATEPID:
|
||||||
|
logger.log(u"Removing pidfile " + str(sickbeard.PIDFILE))
|
||||||
|
sickbeard.remove_pid_file(sickbeard.PIDFILE)
|
||||||
|
break
|
||||||
|
|
||||||
|
# restart
|
||||||
|
logger.log("Restarting SickRage, please stand by...")
|
@ -13,7 +13,7 @@ else
|
|||||||
var base_url = window.location.protocol+'//'+window.location.host+sbRoot;
|
var base_url = window.location.protocol+'//'+window.location.host+sbRoot;
|
||||||
var is_alive_url = sbRoot+'/home/is_alive';
|
var is_alive_url = sbRoot+'/home/is_alive';
|
||||||
var timeout_id;
|
var timeout_id;
|
||||||
var current_pid = '';
|
var restarted = '';
|
||||||
var num_restart_waits = 0;
|
var num_restart_waits = 0;
|
||||||
|
|
||||||
function is_alive() {
|
function is_alive() {
|
||||||
@ -28,9 +28,9 @@ function is_alive() {
|
|||||||
setTimeout('is_alive()', 1000);
|
setTimeout('is_alive()', 1000);
|
||||||
} else {
|
} else {
|
||||||
// if this is before we've even shut down then just try again later
|
// if this is before we've even shut down then just try again later
|
||||||
if (current_pid == '' || data.msg == current_pid) {
|
if (restarted == '' || data.restarted == restarted) {
|
||||||
current_pid = data.msg;
|
restarted = data.restarted;
|
||||||
setTimeout(is_alive, 1000);
|
setTimeout('is_alive()', 1000);
|
||||||
|
|
||||||
// if we're ready to go then redirect to new url
|
// if we're ready to go then redirect to new url
|
||||||
} else {
|
} else {
|
||||||
|
@ -477,7 +477,7 @@ def initialize(consoleLogging=True):
|
|||||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, REMOTE_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, REMOTE_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
||||||
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
||||||
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
||||||
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT
|
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT, RES
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
@ -1309,44 +1309,9 @@ def cleanup_tornado_sockets(io_loop):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def saveAndShutdown():
|
def saveAndShutdown():
|
||||||
|
|
||||||
halt()
|
halt()
|
||||||
saveAll()
|
saveAll()
|
||||||
|
|
||||||
cleanup_tornado_sockets(IOLoop.current())
|
|
||||||
|
|
||||||
if CREATEPID:
|
|
||||||
logger.log(u"Removing pidfile " + str(PIDFILE))
|
|
||||||
remove_pid_file(PIDFILE)
|
|
||||||
|
|
||||||
if restarted:
|
|
||||||
install_type = versionCheckScheduler.action.install_type
|
|
||||||
|
|
||||||
popen_list = []
|
|
||||||
|
|
||||||
if install_type in ('git', 'source'):
|
|
||||||
popen_list = [sys.executable, MY_FULLNAME]
|
|
||||||
elif install_type == 'win':
|
|
||||||
if hasattr(sys, 'frozen'):
|
|
||||||
# c:\dir\to\updater.exe 12345 c:\dir\to\sickbeard.exe
|
|
||||||
popen_list = [os.path.join(PROG_DIR, 'updater.exe'), str(PID), sys.executable]
|
|
||||||
else:
|
|
||||||
logger.log(u"Unknown SB launch method, please file a bug report about this", logger.ERROR)
|
|
||||||
popen_list = [sys.executable, os.path.join(PROG_DIR, 'updater.py'), str(PID), sys.executable,
|
|
||||||
MY_FULLNAME]
|
|
||||||
|
|
||||||
if popen_list:
|
|
||||||
popen_list += MY_ARGS
|
|
||||||
if '--nolaunch' not in popen_list:
|
|
||||||
popen_list += ['--nolaunch']
|
|
||||||
|
|
||||||
logger.log(u"Restarting SickRage with " + str(popen_list))
|
|
||||||
logger.close()
|
|
||||||
|
|
||||||
subprocess.Popen(popen_list, cwd=os.getcwd())
|
|
||||||
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
def invoke_command(to_call, *args, **kwargs):
|
def invoke_command(to_call, *args, **kwargs):
|
||||||
|
|
||||||
def delegate():
|
def delegate():
|
||||||
@ -1375,6 +1340,7 @@ def restart(soft=True):
|
|||||||
initialize()
|
initialize()
|
||||||
else:
|
else:
|
||||||
restarted=True
|
restarted=True
|
||||||
|
time.sleep(5)
|
||||||
webserveInit.shutdown()
|
webserveInit.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
@ -3004,9 +3004,9 @@ class Home(MainHandler):
|
|||||||
self.set_header('Access-Control-Allow-Headers', 'x-requested-with')
|
self.set_header('Access-Control-Allow-Headers', 'x-requested-with')
|
||||||
|
|
||||||
if sickbeard.started:
|
if sickbeard.started:
|
||||||
return callback + '(' + json.dumps({"msg": str(sickbeard.PID)}) + ');'
|
return callback + '(' + json.dumps({"msg": str(sickbeard.PID), "restarted": str(sickbeard.restarted)}) + ');'
|
||||||
else:
|
else:
|
||||||
return callback + '(' + json.dumps({"msg": "nope"}) + ');'
|
return callback + '(' + json.dumps({"msg": "nope", "restarted": str(sickbeard.restarted)}) + ');'
|
||||||
|
|
||||||
|
|
||||||
def index(self, *args, **kwargs):
|
def index(self, *args, **kwargs):
|
||||||
@ -3322,8 +3322,8 @@ class Home(MainHandler):
|
|||||||
t = PageTemplate(file="restart.tmpl")
|
t = PageTemplate(file="restart.tmpl")
|
||||||
t.submenu = HomeMenu()
|
t.submenu = HomeMenu()
|
||||||
|
|
||||||
# do a soft restart
|
# restart
|
||||||
threading.Timer(2, sickbeard.invoke_restart, [False]).start()
|
threading.Timer(5, sickbeard.invoke_restart, [False]).start()
|
||||||
|
|
||||||
return _munge(t)
|
return _munge(t)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
import time
|
||||||
import sickbeard
|
import sickbeard
|
||||||
import webserve
|
import webserve
|
||||||
import webapi
|
import webapi
|
||||||
@ -114,10 +115,10 @@ def initWebServer(options={}):
|
|||||||
def shutdown():
|
def shutdown():
|
||||||
global server
|
global server
|
||||||
|
|
||||||
logger.log('Shutting down tornado')
|
logger.log('Shutting down tornado io loop')
|
||||||
try:
|
try:
|
||||||
IOLoop.current().stop()
|
IOLoop.current().stop()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
logger.log('Failed shutting down the server: %s' % traceback.format_exc(), logger.ERROR)
|
logger.log('Failed shutting down tornado io loop: %s' % traceback.format_exc(), logger.ERROR)
|
Loading…
Reference in New Issue
Block a user