This commit is contained in:
Ozzieisaacs 2018-10-30 19:29:33 +01:00
parent 3f83be00fd
commit 5fc742c9c4

View File

@ -40,11 +40,16 @@ class server:
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)
self.wsgiserver.serve_forever() self.wsgiserver.serve_forever()
except SocketError: except SocketError:
web.app.logger.info('Unable to listen on \'\', trying on IPv4 only...') try:
self.wsgiserver = WSGIServer(('0.0.0.0', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args) web.app.logger.info('Unable to listen on \'\', trying on IPv4 only...')
self.wsgiserver.serve_forever() self.wsgiserver = WSGIServer(('0.0.0.0', web.ub.config.config_port), web.app, spawn=Pool(), **ssl_args)
self.wsgiserver.serve_forever()
except (OSError, SocketError) as e:
web.app.logger.info("Error starting server: %s" % e.strerror)
print("Error starting server: %s" % e.strerror)
web.helper.global_WorkerThread.stop()
sys.exit(1)
except Exception: except Exception:
web.app.logger.info("Unknown error while starting gevent") web.app.logger.info("Unknown error while starting gevent")
@ -54,21 +59,27 @@ class server:
# leave subprocess out to allow forking for fetchers and processors # leave subprocess out to allow forking for fetchers and processors
self.start_gevent() self.start_gevent()
else: else:
web.app.logger.info('Starting Tornado server') try:
if web.ub.config.get_config_certfile() and web.ub.config.get_config_keyfile(): web.app.logger.info('Starting Tornado server')
ssl={"certfile": web.ub.config.get_config_certfile(), if web.ub.config.get_config_certfile() and web.ub.config.get_config_keyfile():
"keyfile": web.ub.config.get_config_keyfile()} ssl={"certfile": web.ub.config.get_config_certfile(),
else: "keyfile": web.ub.config.get_config_keyfile()}
ssl=None else:
# Max Buffersize set to 200MB ssl=None
http_server = HTTPServer(WSGIContainer(web.app), # Max Buffersize set to 200MB
max_buffer_size = 209700000, http_server = HTTPServer(WSGIContainer(web.app),
ssl_options=ssl) max_buffer_size = 209700000,
http_server.listen(web.ub.config.config_port) ssl_options=ssl)
self.wsgiserver=IOLoop.instance() http_server.listen(web.ub.config.config_port)
self.wsgiserver.start() self.wsgiserver=IOLoop.instance()
# wait for stop signal self.wsgiserver.start()
self.wsgiserver.close(True) # wait for stop signal
self.wsgiserver.close(True)
except SocketError as e:
web.app.logger.info("Error starting server: %s" % e.strerror)
print("Error starting server: %s" % e.strerror)
web.helper.global_WorkerThread.stop()
sys.exit(1)
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")