mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 20:39:59 +00:00
Stop Scheduler also on reboot
This commit is contained in:
parent
f241b260d7
commit
6afb429185
@ -22,6 +22,7 @@ import errno
|
|||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
import subprocess # nosec
|
import subprocess # nosec
|
||||||
|
from .services.background_scheduler import BackgroundScheduler
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
@ -265,6 +266,12 @@ class WebServer(object):
|
|||||||
subprocess.call(args, close_fds=True) # nosec
|
subprocess.call(args, close_fds=True) # nosec
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def shutdown_scheduler():
|
||||||
|
scheduler = BackgroundScheduler()
|
||||||
|
if scheduler: # and not scheduler.scheduler.STATE_STOPPED:
|
||||||
|
scheduler.scheduler.shutdown()
|
||||||
|
|
||||||
def _killServer(self, __, ___):
|
def _killServer(self, __, ___):
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
@ -273,6 +280,7 @@ class WebServer(object):
|
|||||||
updater_thread.stop()
|
updater_thread.stop()
|
||||||
|
|
||||||
log.info("webserver stop (restart=%s)", restart)
|
log.info("webserver stop (restart=%s)", restart)
|
||||||
|
self.shutdown_scheduler()
|
||||||
self.restart = restart
|
self.restart = restart
|
||||||
if self.wsgiserver:
|
if self.wsgiserver:
|
||||||
if _GEVENT:
|
if _GEVENT:
|
||||||
|
@ -45,8 +45,6 @@ class BackgroundScheduler:
|
|||||||
cls.scheduler = BScheduler()
|
cls.scheduler = BScheduler()
|
||||||
cls.scheduler.start()
|
cls.scheduler.start()
|
||||||
|
|
||||||
atexit.register(lambda: cls.scheduler.shutdown())
|
|
||||||
|
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def schedule(self, func, trigger, name=None):
|
def schedule(self, func, trigger, name=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user