- Use gunicorn

- Add env variable GUNICORN_WORKERS (default: 1)
- new Port (8000)
- You don't need to run "flask deploy" by hand anymore
This commit is contained in:
Patrick Jentsch 2020-04-20 10:11:45 +02:00
parent f91583484e
commit 15373ed00f
5 changed files with 12 additions and 14 deletions

View File

@ -8,7 +8,7 @@ ENV FLASK_APP=nopaque.py
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
EXPOSE 5000 EXPOSE 8000
RUN apt-get update \ RUN apt-get update \

View File

@ -5,10 +5,8 @@ wait-for-it db:5432 --strict --timeout=0
echo "Waiting for redis..." echo "Waiting for redis..."
wait-for-it redis:6379 --strict --timeout=0 wait-for-it redis:6379 --strict --timeout=0
if [ $# -eq 0 ]; then GUNICORN_WORKERS="${GUNICORN_WORKERS:-1}"
venv/bin/python nopaque.py
elif [ $1 == "flask" ]; then source venv/bin/activate
venv/bin/python -m $@ flask deploy
else gunicorn --bind :5000 --workers "${GUNICORN_WORKERS}" --worker-class eventlet nopaque:app
echo "Unknown command"
fi

View File

@ -14,7 +14,7 @@ GITLAB_PASSWORD=
### Flask ### ### Flask ###
FLASK_CONFIG= FLASK_CONFIG=
# SECRET_KEY= SECRET_KEY=
### Flask-Mail ### ### Flask-Mail ###
MAIL_SERVER= MAIL_SERVER=
@ -24,6 +24,9 @@ MAIL_USERNAME=
MAIL_PASSWORD= MAIL_PASSWORD=
MAIL_DEFAULT_SENDER= MAIL_DEFAULT_SENDER=
### Gunicorn ###
GUNICORN_WORKERS=
### nopaque ### ### nopaque ###
NOPAQUE_ADMIN= NOPAQUE_ADMIN=
NOPAQUE_STORAGE= NOPAQUE_STORAGE=

View File

@ -1,6 +1,6 @@
import eventlet import eventlet
eventlet.monkey_patch() # noqa eventlet.monkey_patch() # noqa
from app import create_app, db, socketio from app import create_app, db
from app.models import Corpus, Job, Role, User from app.models import Corpus, Job, Role, User
from flask_migrate import Migrate, upgrade from flask_migrate import Migrate, upgrade
import os import os
@ -34,7 +34,3 @@ def test():
import unittest import unittest
tests = unittest.TestLoader().discover('tests') tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests) unittest.TextTestRunner(verbosity=2).run(tests)
if __name__ == '__main__':
socketio.run(app, host='0.0.0.0')

View File

@ -7,6 +7,7 @@ Flask-SocketIO
Flask-SQLAlchemy Flask-SQLAlchemy
Flask-Table Flask-Table
Flask-WTF Flask-WTF
gunicorn
jsonpatch jsonpatch
psycopg2 psycopg2
redis redis