Container com logs

This commit is contained in:
Clóvis Fabrício Costa 2023-06-14 15:44:23 -03:00
parent 2cf31baf66
commit e76f2c5e9c
3 changed files with 12 additions and 11 deletions

View File

@ -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"]

View File

@ -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()
upgrade()

View File

@ -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", "-"]
#!/bin/bash
export PYTHONUNBUFFERED=1
exec gunicorn -b $GUNICORN_BIND --access-logfile - --error-logfile - $FLASK_APP:app
# exec /bin/bash