1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-25 09:30:31 +00:00

Stop Scheduler also on reboot

This commit is contained in:
Ozzie Isaacs 2023-01-29 09:53:02 +01:00
parent f241b260d7
commit 6afb429185
2 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import errno
import signal
import socket
import subprocess # nosec
from .services.background_scheduler import BackgroundScheduler
try:
from gevent.pywsgi import WSGIServer
@ -265,6 +266,12 @@ class WebServer(object):
subprocess.call(args, close_fds=True) # nosec
return True
@staticmethod
def shutdown_scheduler():
scheduler = BackgroundScheduler()
if scheduler: # and not scheduler.scheduler.STATE_STOPPED:
scheduler.scheduler.shutdown()
def _killServer(self, __, ___):
self.stop()
@ -273,6 +280,7 @@ class WebServer(object):
updater_thread.stop()
log.info("webserver stop (restart=%s)", restart)
self.shutdown_scheduler()
self.restart = restart
if self.wsgiserver:
if _GEVENT:

View File

@ -45,8 +45,6 @@ class BackgroundScheduler:
cls.scheduler = BScheduler()
cls.scheduler.start()
atexit.register(lambda: cls.scheduler.shutdown())
return cls._instance
def schedule(self, func, trigger, name=None):