Bugfix Restart and Stop server on python3
This commit is contained in:
parent
836c6fd245
commit
341dd77b9d
|
@ -61,11 +61,13 @@ class server:
|
||||||
self.wsgiserver= WSGIServer(('0.0.0.0', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
|
self.wsgiserver= WSGIServer(('0.0.0.0', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
|
||||||
else:
|
else:
|
||||||
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
|
||||||
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...')
|
||||||
self.wsgiserver = WSGIServer(('0.0.0.0', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
|
self.wsgiserver = WSGIServer(('0.0.0.0', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
|
||||||
|
web.py3_gevent_link = self.wsgiserver
|
||||||
self.wsgiserver.serve_forever()
|
self.wsgiserver.serve_forever()
|
||||||
except (OSError, SocketError) as e:
|
except (OSError, SocketError) as e:
|
||||||
web.app.logger.info("Error starting server: %s" % e.strerror)
|
web.app.logger.info("Error starting server: %s" % e.strerror)
|
||||||
|
@ -130,6 +132,12 @@ class server:
|
||||||
self.stopServer()
|
self.stopServer()
|
||||||
|
|
||||||
def stopServer(self):
|
def stopServer(self):
|
||||||
|
if sys.version_info > (3, 0):
|
||||||
|
if not self.wsgiserver:
|
||||||
|
if gevent_present:
|
||||||
|
self.wsgiserver = web.py3_gevent_link
|
||||||
|
else:
|
||||||
|
self.wsgiserver = IOLoop.instance()
|
||||||
if self.wsgiserver:
|
if self.wsgiserver:
|
||||||
if gevent_present:
|
if gevent_present:
|
||||||
self.wsgiserver.close()
|
self.wsgiserver.close()
|
||||||
|
|
|
@ -132,6 +132,7 @@ except ImportError:
|
||||||
# Global variables
|
# Global variables
|
||||||
current_milli_time = lambda: int(round(time.time() * 1000))
|
current_milli_time = lambda: int(round(time.time() * 1000))
|
||||||
gdrive_watch_callback_token = 'target=calibreweb-watch_files'
|
gdrive_watch_callback_token = 'target=calibreweb-watch_files'
|
||||||
|
py3_gevent_link = None
|
||||||
EXTENSIONS_UPLOAD = {'txt', 'pdf', 'epub', 'mobi', 'azw', 'azw3', 'cbr', 'cbz', 'cbt', 'djvu', 'prc', 'doc', 'docx',
|
EXTENSIONS_UPLOAD = {'txt', 'pdf', 'epub', 'mobi', 'azw', 'azw3', 'cbr', 'cbz', 'cbt', 'djvu', 'prc', 'doc', 'docx',
|
||||||
'fb2', 'html', 'rtf', 'odt'}
|
'fb2', 'html', 'rtf', 'odt'}
|
||||||
EXTENSIONS_CONVERT = {'pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz'}
|
EXTENSIONS_CONVERT = {'pdf', 'epub', 'mobi', 'azw3', 'docx', 'rtf', 'fb2', 'lit', 'lrf', 'txt', 'htmlz'}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user