From 01019c22d9314c69fb149f61a9f71c09f70bea95 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Mon, 18 Apr 2016 08:13:27 +0200 Subject: [PATCH] add switch for debugger --- README.md | 8 +++++++- app/main.py | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 65a01f0..5054800 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,13 @@ `docker build --tag=$(basename $PWD) .` ## run in development -`docker run --name rollerverbrauch -ti -v `pwd`/app:/app -p 5000:5000 rollerverbrauch` + +Include the development version of the code as volume, so the app gets +reloaded automatically. The sqlite file will be stored in *tmp* so it +can be inspected with tools like *sqlite3*. The switch *DEBUG* enables +debugging during development. + +`docker run --name rollerverbrauch -ti -v `pwd`/app:/app -v /tmp/pitstops/:/data -e DEBUG=True -p 5000:5000 rollerverbrauch` ## run in production `docker run --name pitstops -d -v /data/pitstops/:/data -p 80:5000 rollerverbrauch` \ No newline at end of file diff --git a/app/main.py b/app/main.py index de85eb0..da1ebd4 100644 --- a/app/main.py +++ b/app/main.py @@ -9,13 +9,13 @@ import uuid import hashlib import time from functools import wraps +import os app = Flask(__name__) DATABASE = '/data/rollerverbrauch.db' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+DATABASE sqldb = SQLAlchemy(app) -DEBUG = True SECRET_KEY = 'development key' app.config.from_object(__name__) @@ -236,4 +236,5 @@ def prepare_pit_stops(pss): return pitstops if __name__ == '__main__': - app.run(debug=True, host='0.0.0.0') + DEBUG = 'DEBUG' in os.environ and os.environ['DEBUG'] != 'False' + app.run(debug=DEBUG, host='0.0.0.0')