From 4e67c145121f5dd1f2557a9404cb25dab566e0cd Mon Sep 17 00:00:00 2001 From: Matt Webb Date: Sat, 27 Sep 2014 13:24:41 +0100 Subject: [PATCH] preparing to do a test deploy to heroku --- Procfile | 1 + config.py | 53 +++++++++++++++++++++++++++++++++++++----------- requirements.txt | 1 + 3 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..ff76cd9 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn -k flask_sockets.worker manage:app diff --git a/config.py b/config.py index 49993cf..dfb1eb5 100755 --- a/config.py +++ b/config.py @@ -3,20 +3,49 @@ basedir = os.path.abspath(os.path.dirname(__file__)) class Config: - SECRET_KEY = os.environ.get('SECRET_KEY') or 'this is the lp2 secret' - SQLALCHEMY_COMMIT_ON_TEARDOWN = True - - @staticmethod - def init_app(app): - pass + SECRET_KEY = os.environ.get('SECRET_KEY') or 'this is the lp2 secret' + SQLALCHEMY_COMMIT_ON_TEARDOWN = True + + @staticmethod + def init_app(app): + pass class DevelopmentConfig(Config): - DEBUG = True - SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \ - 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite') + DEBUG = True + SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \ + 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite') + +class ProductionConfig(Config): + SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \ + 'sqlite:///' + os.path.join(basedir, 'data.sqlite') + + @classmethod + def init_app(cls, app): + Config.init_app(app) + +class HerokuConfig(ProductionConfig): + SSL_DISABLE = bool(os.environ.get('SSL_DISABLE')) + + @classmethod + def init_app(cls, app): + ProductionConfig.init_app(app) + + # handle proxy server headers + from werkzeug.contrib.fixers import ProxyFix + app.wsgi_app = ProxyFix(app.wsgi_app) + + # log to stderr + import logging + from logging import StreamHandler + file_handler = StreamHandler() + file_handler.setLevel(logging.WARNING) + app.logger.addHandler(file_handler) + config = { - 'development': DevelopmentConfig, - - 'default': DevelopmentConfig + 'development': DevelopmentConfig, + 'production': ProductionConfig, + 'heroku': HerokuConfig, + + 'default': DevelopmentConfig } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index a5502ba..4e2ed5c 100755 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,7 @@ gevent-websocket==0.9.3 greenlet==0.4.4 gunicorn==19.1.1 itsdangerous==0.24 +psycopg2==2.5.4 pycrypto==2.6.1 redis==2.10.3 selenium==2.43.0 -- 2.47.3