Chapter 18: Deployment on Heroku (v0.18)
This commit is contained in:
parent
fbba803e1d
commit
564a94c614
|
@ -0,0 +1 @@
|
||||||
|
web: flask db upgrade; flask translate compile; gunicorn microblog:app
|
|
@ -63,6 +63,11 @@ def create_app(config_class=Config):
|
||||||
mail_handler.setLevel(logging.ERROR)
|
mail_handler.setLevel(logging.ERROR)
|
||||||
app.logger.addHandler(mail_handler)
|
app.logger.addHandler(mail_handler)
|
||||||
|
|
||||||
|
if app.config['LOG_TO_STDOUT']:
|
||||||
|
stream_handler = logging.StreamHandler()
|
||||||
|
stream_handler.setLevel(logging.INFO)
|
||||||
|
app.logger.addHandler(stream_handler)
|
||||||
|
else:
|
||||||
if not os.path.exists('logs'):
|
if not os.path.exists('logs'):
|
||||||
os.mkdir('logs')
|
os.mkdir('logs')
|
||||||
file_handler = RotatingFileHandler('logs/microblog.log',
|
file_handler = RotatingFileHandler('logs/microblog.log',
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Config(object):
|
||||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
||||||
'sqlite:///' + os.path.join(basedir, 'app.db')
|
'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT')
|
||||||
MAIL_SERVER = os.environ.get('MAIL_SERVER')
|
MAIL_SERVER = os.environ.get('MAIL_SERVER')
|
||||||
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
|
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
|
||||||
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
||||||
|
|
|
@ -33,3 +33,7 @@ urllib3==1.22
|
||||||
visitor==0.1.3
|
visitor==0.1.3
|
||||||
Werkzeug==0.12.2
|
Werkzeug==0.12.2
|
||||||
WTForms==2.1
|
WTForms==2.1
|
||||||
|
|
||||||
|
# requirements for Heroku
|
||||||
|
psycopg2==2.7.3.1
|
||||||
|
gunicorn==19.7.1
|
||||||
|
|
Loading…
Reference in New Issue