From 4ea529d88f217bebd2efb2ed24bcdc04eb80448b Mon Sep 17 00:00:00 2001 From: root <root@onni.utu.fi> Date: Tue, 6 Nov 2018 15:44:22 +0200 Subject: [PATCH] Updated requirements and startup script --- .gitignore | 2 ++ requirements.txt | 3 +++ run.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 run.py diff --git a/.gitignore b/.gitignore index e11292b..acce3a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ __pycache__/ /venv +/logs cmd.txt DB_inserts.txt dumb.sql scrap_script.py *.pyc +*.db diff --git a/requirements.txt b/requirements.txt index 2bd4d95..1d3586c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ alembic==0.9.9 click==6.7 dominate==2.3.1 Flask==1.0.2 +Flask-Babel Flask-Bootstrap==3.3.7.1 Flask-Login==0.4.1 Flask-Migrate==2.2.1 @@ -22,3 +23,5 @@ visitor==0.1.3 Werkzeug==0.14.1 WTForms==2.2.1 WTForms-SQLAlchemy==0.1 +pyexcel +gunicorn==19.9.0 diff --git a/run.py b/run.py new file mode 100644 index 0000000..60d5d24 --- /dev/null +++ b/run.py @@ -0,0 +1,49 @@ +from app import app + + +# Setup logging +import logging +from logging.handlers import RotatingFileHandler +from logging import Formatter + +format = "[%(asctime)s] p%(process)s\n" \ + "[%(levelname)s] in %(name)s: %(filename)s:%(lineno)d\n" \ + "%(message)s\n" + +logging.basicConfig( + filename=app.config.get('LOG_FILENAME', 'logs/flask.log'), + level=logging.DEBUG, + datefmt="%Y-%m-%d %H:%M:%S", + format = format +) + +logging.info( + "\n" + "==============================================================\n" + "Mega-fMRI stimulus Rating Tool Flask application started\n" + "PET-keskus (2018) \n" +) + +handler = RotatingFileHandler('logs/flask.log', maxBytes=10000, backupCount=5) +handler.setFormatter( + Formatter(format) +) +app.logger.addHandler(handler) + +# Logging for production (nginx + gunicorn) +import os +is_gunicorn = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "") +if is_gunicorn: + app.logger.info("Application run through gunicorn") + gunicorn_logger = logging.getLogger('gunicorn.error') + app.logger.handlers = gunicorn_logger.handlers + app.logger.setLevel(gunicorn_logger.level) + app.logger.info("******************") + ''' +else: + log = logging.getLogger('werkzeug') + log.setLevel(logging.ERROR) + ''' + +# EOF + -- GitLab