|
|
@ -25,7 +25,7 @@ import signal
|
|
|
|
import web
|
|
|
|
import web
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from gevent.pywsgi import WSGIServer
|
|
|
|
from gevent.piwsgi import WSGIServer
|
|
|
|
from gevent.pool import Pool
|
|
|
|
from gevent.pool import Pool
|
|
|
|
from gevent import __version__ as geventVersion
|
|
|
|
from gevent import __version__ as geventVersion
|
|
|
|
gevent_present = True
|
|
|
|
gevent_present = True
|
|
|
@ -37,6 +37,7 @@ except ImportError:
|
|
|
|
gevent_present = False
|
|
|
|
gevent_present = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class server:
|
|
|
|
class server:
|
|
|
|
|
|
|
|
|
|
|
|
wsgiserver = None
|
|
|
|
wsgiserver = None
|
|
|
@ -63,6 +64,7 @@ class server:
|
|
|
|
self.wsgiserver = WSGIServer(('', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
|
|
|
|
self.wsgiserver = WSGIServer(('', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
|
|
|
|
web.py3_gevent_link = self.wsgiserver
|
|
|
|
web.py3_gevent_link = self.wsgiserver
|
|
|
|
self.wsgiserver.serve_forever()
|
|
|
|
self.wsgiserver.serve_forever()
|
|
|
|
|
|
|
|
|
|
|
|
except SocketError:
|
|
|
|
except SocketError:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
web.app.logger.info('Unable to listen on \'\', trying on IPv4 only...')
|
|
|
|
web.app.logger.info('Unable to listen on \'\', trying on IPv4 only...')
|
|
|
@ -110,6 +112,9 @@ class server:
|
|
|
|
web.helper.global_WorkerThread.stop()
|
|
|
|
web.helper.global_WorkerThread.stop()
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ToDo: Somehow caused by circular import under python3 refactor
|
|
|
|
|
|
|
|
if sys.version_info > (3, 0):
|
|
|
|
|
|
|
|
self.restart = web.py3_restart_Typ
|
|
|
|
if self.restart == True:
|
|
|
|
if self.restart == True:
|
|
|
|
web.app.logger.info("Performing restart of Calibre-Web")
|
|
|
|
web.app.logger.info("Performing restart of Calibre-Web")
|
|
|
|
web.helper.global_WorkerThread.stop()
|
|
|
|
web.helper.global_WorkerThread.stop()
|
|
|
@ -126,12 +131,15 @@ class server:
|
|
|
|
sys.exit(0)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
def setRestartTyp(self,starttyp):
|
|
|
|
def setRestartTyp(self,starttyp):
|
|
|
|
self.restart=starttyp
|
|
|
|
self.restart = starttyp
|
|
|
|
|
|
|
|
# ToDo: Somehow caused by circular import under python3 refactor
|
|
|
|
|
|
|
|
web.py3_restart_Typ = starttyp
|
|
|
|
|
|
|
|
|
|
|
|
def killServer(self, signum, frame):
|
|
|
|
def killServer(self, signum, frame):
|
|
|
|
self.stopServer()
|
|
|
|
self.stopServer()
|
|
|
|
|
|
|
|
|
|
|
|
def stopServer(self):
|
|
|
|
def stopServer(self):
|
|
|
|
|
|
|
|
# ToDo: Somehow caused by circular import under python3 refactor
|
|
|
|
if sys.version_info > (3, 0):
|
|
|
|
if sys.version_info > (3, 0):
|
|
|
|
if not self.wsgiserver:
|
|
|
|
if not self.wsgiserver:
|
|
|
|
if gevent_present:
|
|
|
|
if gevent_present:
|
|
|
|