Adding gunicorn as a multi-threaded production server

This commit is contained in:
Maxime Beauchemin 2015-08-25 11:57:09 -07:00
parent acd14afd4e
commit 8e5a827b75
4 changed files with 18 additions and 5 deletions

View File

@ -102,7 +102,7 @@ form input.form-control {
<hr/>
{% block viz %}
{% if error_msg %}
<div class="alert alert-danger">{{ error_msg }}</div>
<span class="alert alert-danger">{{ error_msg }}</span>
{% endif %}
{% endblock %}

View File

@ -13,6 +13,7 @@ There' a ``from local_config import *`` at the end of this file.
# Panoramix specifix config
#---------------------------------------------------------
ROW_LIMIT = 5000
WEBSERVER_THREADS = 8
PANORAMIX_WEBSERVER_PORT = 8088
#---------------------------------------------------------

View File

@ -1,6 +1,7 @@
flask
flask-alembic
flask-appbuilder
gunicorn
mysql-python
pandas
parsedatetime

19
run.py
View File

@ -1,8 +1,19 @@
from app import app
import config
from subprocess import Popen
if config.DEBUG:
app.run(
host='0.0.0.0',
port=int(config.PANORAMIX_WEBSERVER_PORT),
debug=True)
else:
cmd = (
"gunicorn "
"-w 8 "
"-b 0.0.0.0:{config.PANORAMIX_WEBSERVER_PORT} "
"app:app").format(**locals())
print("Starting server with command: " + cmd)
Popen(cmd, shell=True).wait()
app.run(
host='0.0.0.0',
port=int(config.PANORAMIX_WEBSERVER_PORT),
debug=config.DEBUG)