mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 19:12:26 -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
|
# check for commands to be executed in the background
|
||||||
task = PeriodicCallback(invoke_command, 1000)
|
task = PeriodicCallback(invoke_command, 1000)
|
||||||
task.start()
|
sickbeard.WEBSERVER.tasks.append(task)
|
||||||
|
|
||||||
# start tornado
|
# start tornado
|
||||||
sickbeard.WEBSERVER.start()
|
sickbeard.WEBSERVER.start()
|
||||||
|
@ -1117,12 +1117,15 @@ def start():
|
|||||||
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
|
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
|
||||||
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
|
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
|
||||||
subtitlesFinderScheduler, USE_SUBTITLES,traktWatchListCheckerScheduler, \
|
subtitlesFinderScheduler, USE_SUBTITLES,traktWatchListCheckerScheduler, \
|
||||||
dailySearchScheduler, started
|
dailySearchScheduler, WEBSERVER, started
|
||||||
|
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
|
|
||||||
|
# start IOLoop tasks
|
||||||
|
WEBSERVER.start_tasks()
|
||||||
|
|
||||||
# start the maintenance scheduler
|
# start the maintenance scheduler
|
||||||
maintenanceScheduler.thread.start()
|
maintenanceScheduler.thread.start()
|
||||||
logger.log(u"Performing initial maintenance tasks, please wait ...")
|
logger.log(u"Performing initial maintenance tasks, please wait ...")
|
||||||
@ -1168,7 +1171,7 @@ def halt():
|
|||||||
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
|
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
|
||||||
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
|
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
|
||||||
subtitlesFinderScheduler, traktWatchListCheckerScheduler, \
|
subtitlesFinderScheduler, traktWatchListCheckerScheduler, \
|
||||||
dailySearchScheduler, started
|
dailySearchScheduler, WEBSERVER, started
|
||||||
|
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
||||||
@ -1178,6 +1181,8 @@ def halt():
|
|||||||
|
|
||||||
# abort all the threads
|
# abort all the threads
|
||||||
|
|
||||||
|
WEBSERVER.stop_tasks()
|
||||||
|
|
||||||
maintenanceScheduler.abort = True
|
maintenanceScheduler.abort = True
|
||||||
logger.log(u"Waiting for the MAINTENANCE scheduler thread to exit")
|
logger.log(u"Waiting for the MAINTENANCE scheduler thread to exit")
|
||||||
try:
|
try:
|
||||||
|
@ -40,6 +40,7 @@ class webserverInit():
|
|||||||
|
|
||||||
self.server = None
|
self.server = None
|
||||||
self.ioloop = None
|
self.ioloop = None
|
||||||
|
self.tasks = []
|
||||||
|
|
||||||
self.options = options
|
self.options = options
|
||||||
self.options.setdefault('port', 8081)
|
self.options.setdefault('port', 8081)
|
||||||
@ -155,4 +156,12 @@ class webserverInit():
|
|||||||
self.ioloop.stop()
|
self.ioloop.stop()
|
||||||
|
|
||||||
def close(self):
|
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