mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-06 03:18:01 -05:00
Fixed shutdown to completely stop and close IOLoop.
This commit is contained in:
parent
af6cd334a0
commit
acca01eb90
12
SickBeard.py
12
SickBeard.py
@ -48,7 +48,6 @@ if sys.hexversion >= 0x020600F0:
|
|||||||
import locale
|
import locale
|
||||||
import datetime
|
import datetime
|
||||||
import threading
|
import threading
|
||||||
import time
|
|
||||||
import signal
|
import signal
|
||||||
import traceback
|
import traceback
|
||||||
import getopt
|
import getopt
|
||||||
@ -65,6 +64,8 @@ from sickbeard.databases.mainDB import MAX_DB_VERSION
|
|||||||
|
|
||||||
from lib.configobj import ConfigObj
|
from lib.configobj import ConfigObj
|
||||||
|
|
||||||
|
from tornado.ioloop import IOLoop, PeriodicCallback
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, sickbeard.sig_handler)
|
signal.signal(signal.SIGINT, sickbeard.sig_handler)
|
||||||
signal.signal(signal.SIGTERM, sickbeard.sig_handler)
|
signal.signal(signal.SIGTERM, sickbeard.sig_handler)
|
||||||
|
|
||||||
@ -372,6 +373,9 @@ def main():
|
|||||||
logger.log(u"Loading initial show list")
|
logger.log(u"Loading initial show list")
|
||||||
loadShowsFromDB()
|
loadShowsFromDB()
|
||||||
|
|
||||||
|
# Fire up all our threads
|
||||||
|
sickbeard.start()
|
||||||
|
|
||||||
# Launch browser if we're supposed to
|
# Launch browser if we're supposed to
|
||||||
if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
|
if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
|
||||||
sickbeard.launchBrowser(startPort)
|
sickbeard.launchBrowser(startPort)
|
||||||
@ -384,15 +388,13 @@ def main():
|
|||||||
sickbeard.WEBSERVER = webserverInit(options)
|
sickbeard.WEBSERVER = webserverInit(options)
|
||||||
sickbeard.WEBSERVER.ioloop.add_timeout(datetime.timedelta(seconds=5), startup)
|
sickbeard.WEBSERVER.ioloop.add_timeout(datetime.timedelta(seconds=5), startup)
|
||||||
|
|
||||||
# Fire up all our threads
|
|
||||||
sickbeard.start()
|
|
||||||
|
|
||||||
# check for commands to be executed in the background
|
# check for commands to be executed in the background
|
||||||
task = tornado.ioloop.PeriodicCallback(invoke_command, 1000)
|
task = PeriodicCallback(invoke_command, 1000)
|
||||||
task.start()
|
task.start()
|
||||||
|
|
||||||
# start tornado
|
# start tornado
|
||||||
sickbeard.WEBSERVER.start()
|
sickbeard.WEBSERVER.start()
|
||||||
|
sickbeard.WEBSERVER.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -1296,6 +1296,14 @@ def saveAndShutdown(restart=False):
|
|||||||
halt()
|
halt()
|
||||||
saveAll()
|
saveAll()
|
||||||
|
|
||||||
|
logger.log('Shutting down tornado')
|
||||||
|
try:
|
||||||
|
WEBSERVER.stop()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
logger.log('Failed shutting down the server: %s' % traceback.format_exc(), logger.ERROR)
|
||||||
|
|
||||||
if CREATEPID:
|
if CREATEPID:
|
||||||
logger.log(u"Removing pidfile " + str(PIDFILE))
|
logger.log(u"Removing pidfile " + str(PIDFILE))
|
||||||
remove_pid_file(PIDFILE)
|
remove_pid_file(PIDFILE)
|
||||||
@ -1326,14 +1334,6 @@ def saveAndShutdown(restart=False):
|
|||||||
|
|
||||||
subprocess.Popen(popen_list, cwd=os.getcwd())
|
subprocess.Popen(popen_list, cwd=os.getcwd())
|
||||||
|
|
||||||
logger.log('Shutting down tornado')
|
|
||||||
try:
|
|
||||||
WEBSERVER.stop()
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
logger.log('Failed shutting down the server: %s' % traceback.format_exc(), logger.ERROR)
|
|
||||||
|
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class webserverInit():
|
|||||||
self.abort = False
|
self.abort = False
|
||||||
|
|
||||||
self.server = None
|
self.server = None
|
||||||
self.ioloop = IOLoop.instance()
|
self.ioloop = None
|
||||||
|
|
||||||
self.options = options
|
self.options = options
|
||||||
self.options.setdefault('port', 8081)
|
self.options.setdefault('port', 8081)
|
||||||
@ -145,10 +145,14 @@ class webserverInit():
|
|||||||
logger.log(u"Starting SickRage on " + protocol + "://" + str(self.options['host']) + ":" + str(
|
logger.log(u"Starting SickRage on " + protocol + "://" + str(self.options['host']) + ":" + str(
|
||||||
self.options['port']) + "/")
|
self.options['port']) + "/")
|
||||||
|
|
||||||
|
self.ioloop = IOLoop.current()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.server.listen(self.options['port'], self.options['host'])
|
self.server.listen(self.options['port'], self.options['host'])
|
||||||
self.ioloop.start()
|
self.ioloop.start()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.server.stop()
|
self.ioloop.stop()
|
||||||
self.ioloop.stop()
|
|
||||||
|
def close(self):
|
||||||
|
self.ioloop.close()
|
Loading…
Reference in New Issue
Block a user