1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

IOLoop tasks are now started and stopped via regular start and halt sickrage functions allowing us to gracefully exit on shutdown or restart.

This commit is contained in:
echel0n 2014-06-15 06:59:51 -07:00
parent acca01eb90
commit fa01711192
3 changed files with 18 additions and 4 deletions

View File

@ -390,7 +390,7 @@ def main():
# check for commands to be executed in the background
task = PeriodicCallback(invoke_command, 1000)
task.start()
sickbeard.WEBSERVER.tasks.append(task)
# start tornado
sickbeard.WEBSERVER.start()

View File

@ -1117,12 +1117,15 @@ def start():
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
subtitlesFinderScheduler, USE_SUBTITLES,traktWatchListCheckerScheduler, \
dailySearchScheduler, started
dailySearchScheduler, WEBSERVER, started
with INIT_LOCK:
if __INITIALIZED__:
# start IOLoop tasks
WEBSERVER.start_tasks()
# start the maintenance scheduler
maintenanceScheduler.thread.start()
logger.log(u"Performing initial maintenance tasks, please wait ...")
@ -1168,7 +1171,7 @@ def halt():
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
subtitlesFinderScheduler, traktWatchListCheckerScheduler, \
dailySearchScheduler, started
dailySearchScheduler, WEBSERVER, started
with INIT_LOCK:
@ -1178,6 +1181,8 @@ def halt():
# abort all the threads
WEBSERVER.stop_tasks()
maintenanceScheduler.abort = True
logger.log(u"Waiting for the MAINTENANCE scheduler thread to exit")
try:

View File

@ -40,6 +40,7 @@ class webserverInit():
self.server = None
self.ioloop = None
self.tasks = []
self.options = options
self.options.setdefault('port', 8081)
@ -155,4 +156,12 @@ class webserverInit():
self.ioloop.stop()
def close(self):
self.ioloop.close()
self.ioloop.close()
def start_tasks(self):
for task in self.tasks:
task.start()
def stop_tasks(self):
for task in self.tasks:
task.stop()