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:
parent
acca01eb90
commit
fa01711192
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user