Use cheroot as default production server for pgAdmin4. Fixes #5017
If DEBUG is true then we used the default flask server.pull/27/head
parent
a6841bb1e1
commit
15c518f0f1
|
|
@ -14,6 +14,7 @@ New features
|
||||||
Housekeeping
|
Housekeeping
|
||||||
************
|
************
|
||||||
|
|
||||||
|
| `Issue #5017 <https://redmine.postgresql.org/issues/5017>`_ - Use cheroot as default production server for pgAdmin4.
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
*********
|
*********
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
# ignored when building a PIP Wheel.
|
# ignored when building a PIP Wheel.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
blinker==1.4
|
blinker==1.4
|
||||||
|
cheroot==8.2.1
|
||||||
Flask==1.0.2
|
Flask==1.0.2
|
||||||
Werkzeug>=0.15.0
|
Werkzeug>=0.15.0
|
||||||
Flask-Gravatar==0.5.0
|
Flask-Gravatar==0.5.0
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ to start a web server."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from cheroot.wsgi import Server as CherootServer
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
import builtins
|
import builtins
|
||||||
|
|
@ -190,15 +191,29 @@ if __name__ == '__main__':
|
||||||
# Reference:
|
# Reference:
|
||||||
# https://github.com/pallets/werkzeug/issues/220#issuecomment-11176538
|
# https://github.com/pallets/werkzeug/issues/220#issuecomment-11176538
|
||||||
try:
|
try:
|
||||||
app.run(
|
if config.DEBUG:
|
||||||
host=config.DEFAULT_SERVER,
|
app.run(
|
||||||
port=server_port,
|
host=config.DEFAULT_SERVER,
|
||||||
use_reloader=(
|
port=server_port,
|
||||||
(not PGADMIN_RUNTIME) and app.debug and
|
use_reloader=(
|
||||||
os.environ.get("WERKZEUG_RUN_MAIN") is not None
|
(not PGADMIN_RUNTIME) and app.debug and
|
||||||
),
|
os.environ.get("WERKZEUG_RUN_MAIN") is not None
|
||||||
threaded=config.THREADED_MODE
|
),
|
||||||
)
|
threaded=config.THREADED_MODE
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Can use cheroot instead of flask dev server when not in debug
|
||||||
|
# 10 is default thread count in CherootServer
|
||||||
|
num_threads = 10 if config.THREADED_MODE else 1
|
||||||
|
prod_server = CherootServer(
|
||||||
|
(config.DEFAULT_SERVER, server_port),
|
||||||
|
wsgi_app=app,
|
||||||
|
numthreads=num_threads,
|
||||||
|
server_name=config.APP_NAME)
|
||||||
|
try:
|
||||||
|
print("Using production server...")
|
||||||
|
prod_server.start()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
prod_server.stop()
|
||||||
except IOError:
|
except IOError:
|
||||||
app.logger.error("Error starting the app server: %s", sys.exc_info())
|
app.logger.error("Error starting the app server: %s", sys.exc_info())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue