Skip to content

Commit

Permalink
Adding gunicorn as a multi-threaded production server
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Aug 25, 2015
1 parent acd14af commit 8e5a827
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/templates/panoramix/datasource.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h3>{{ viz.verbose_name }}
<hr/>
{% block viz %}
{% if error_msg %}
<div class="alert alert-danger">{{ error_msg }}</div>
<span class="alert alert-danger">{{ error_msg }}</span>
{% endif %}
{% endblock %}

Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Panoramix specifix config
#---------------------------------------------------------
ROW_LIMIT = 5000
WEBSERVER_THREADS = 8

PANORAMIX_WEBSERVER_PORT = 8088
#---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
flask
flask-alembic
flask-appbuilder
gunicorn
mysql-python
pandas
parsedatetime
Expand Down
19 changes: 15 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8e5a827

Please sign in to comment.