mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Fixed shutdown to completely stop and close IOLoop.
This commit is contained in:
parent
af6cd334a0
commit
acca01eb90
3 changed files with 22 additions and 16 deletions
12
SickBeard.py
12
SickBeard.py
|
@ -48,7 +48,6 @@ if sys.hexversion >= 0x020600F0:
|
|||
import locale
|
||||
import datetime
|
||||
import threading
|
||||
import time
|
||||
import signal
|
||||
import traceback
|
||||
import getopt
|
||||
|
@ -65,6 +64,8 @@ from sickbeard.databases.mainDB import MAX_DB_VERSION
|
|||
|
||||
from lib.configobj import ConfigObj
|
||||
|
||||
from tornado.ioloop import IOLoop, PeriodicCallback
|
||||
|
||||
signal.signal(signal.SIGINT, sickbeard.sig_handler)
|
||||
signal.signal(signal.SIGTERM, sickbeard.sig_handler)
|
||||
|
||||
|
@ -372,6 +373,9 @@ def main():
|
|||
logger.log(u"Loading initial show list")
|
||||
loadShowsFromDB()
|
||||
|
||||
# Fire up all our threads
|
||||
sickbeard.start()
|
||||
|
||||
# Launch browser if we're supposed to
|
||||
if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
|
||||
sickbeard.launchBrowser(startPort)
|
||||
|
@ -384,15 +388,13 @@ def main():
|
|||
sickbeard.WEBSERVER = webserverInit(options)
|
||||
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
|
||||
task = tornado.ioloop.PeriodicCallback(invoke_command, 1000)
|
||||
task = PeriodicCallback(invoke_command, 1000)
|
||||
task.start()
|
||||
|
||||
# start tornado
|
||||
sickbeard.WEBSERVER.start()
|
||||
sickbeard.WEBSERVER.close()
|
||||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1296,6 +1296,14 @@ def saveAndShutdown(restart=False):
|
|||
halt()
|
||||
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:
|
||||
logger.log(u"Removing pidfile " + str(PIDFILE))
|
||||
remove_pid_file(PIDFILE)
|
||||
|
@ -1326,14 +1334,6 @@ def saveAndShutdown(restart=False):
|
|||
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class webserverInit():
|
|||
self.abort = False
|
||||
|
||||
self.server = None
|
||||
self.ioloop = IOLoop.instance()
|
||||
self.ioloop = None
|
||||
|
||||
self.options = options
|
||||
self.options.setdefault('port', 8081)
|
||||
|
@ -145,10 +145,14 @@ class webserverInit():
|
|||
logger.log(u"Starting SickRage on " + protocol + "://" + str(self.options['host']) + ":" + str(
|
||||
self.options['port']) + "/")
|
||||
|
||||
self.ioloop = IOLoop.current()
|
||||
|
||||
def start(self):
|
||||
self.server.listen(self.options['port'], self.options['host'])
|
||||
self.ioloop.start()
|
||||
|
||||
def stop(self):
|
||||
self.server.stop()
|
||||
self.ioloop.stop()
|
||||
self.ioloop.stop()
|
||||
|
||||
def close(self):
|
||||
self.ioloop.close()
|
Loading…
Reference in a new issue