diff --git a/Containerfile b/Containerfile index edbc0e5..c774c42 100644 --- a/Containerfile +++ b/Containerfile @@ -15,7 +15,6 @@ COPY migrations ./migrations RUN chmod +x start.sh ENV FLASK_APP=rifaserver.app +ENV GUNICORN_BIND=:5000 ENV PYTHONUNBUFFERED 1 -# CMD ["gunicorn", "-b", ":5000", "rifaserver.app:app", "--access-logfile", "-", "--error-logfile", "-"] -# "--access-logformat", "%({x-forwarded-for}i)s %(l)s %(u)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\""] CMD ["./start.sh"] diff --git a/rifaserver/app.py b/rifaserver/app.py index 57b3081..ba40a24 100644 --- a/rifaserver/app.py +++ b/rifaserver/app.py @@ -67,15 +67,18 @@ def create_app(): migrate = Migrate(app, db) - with app.app_context(): - if not os.path.isfile(os.path.join(app.instance_path, 'raffle.db')): + if not os.path.isfile(os.path.join(app.instance_path, 'raffle.db')): + print('Criando novo banco de dados `raffle.db`') + with app.app_context(): db.create_all() stamp() + import sys + sys.exit() scheduler = BackgroundScheduler() scheduler.add_job(func=backup_db, args=(app.instance_path,), trigger="interval", hours=1) scheduler.start() -# print('App created!!') + return app @@ -232,4 +235,4 @@ def change_password(usuario, nova_senha): @with_appcontext def apply_migrations_command(): """Apply database migrations.""" - upgrade() \ No newline at end of file + upgrade() diff --git a/start.sh b/start.sh index fab4488..a209bc2 100644 --- a/start.sh +++ b/start.sh @@ -1,5 +1,4 @@ -#!/bin/sh -# flask --app rifaserver.app apply_migrations - -exec gunicorn -b :5001 rifaserver.app:app --access-logfile - --error-logfile - -# CMD ["gunicorn", "-b", ":5000", "rifaserver.app:app", "--access-logfile", "-", "--error-logfile", "-"] \ No newline at end of file +#!/bin/bash +export PYTHONUNBUFFERED=1 +exec gunicorn -b $GUNICORN_BIND --access-logfile - --error-logfile - $FLASK_APP:app +# exec /bin/bash