Skip to content

Commit e94d587

Browse files
committed
heroku deployment
1 parent c046233 commit e94d587

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

app/Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: flask db upgrade; flask translate compile; gunicorn microblog:app

app/__init__.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,17 @@ def create_app(config_class=Config):
6868
mail_handler.setLevel(logging.ERROR)
6969
app.logger.addHandler(mail_handler)
7070

71-
if not os.path.exists('logs'):
72-
os.mkdir('logs')
73-
file_handler = RotatingFileHandler('logs/microblog.log', maxBytes=10240, backupCount=10)
74-
file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
75-
file_handler.setLevel(logging.INFO)
76-
app.logger.addHandler(file_handler)
71+
if app.config['LOG_TO_STDOUT']:
72+
stream_handler = logging.StreamHandler()
73+
stream_handler.setLevel(logging.INFO)
74+
app.logger.addHandler(stream_handler)
75+
else:
76+
if not os.path.exists('logs'):
77+
os.mkdir('logs')
78+
file_handler = RotatingFileHandler('logs/microblog.log', maxBytes=10240, backupCount=10)
79+
file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
80+
file_handler.setLevel(logging.INFO)
81+
app.logger.addHandler(file_handler)
7782

7883
app.logger.setLevel(logging.INFO)
7984
app.logger.info('Microblog startup')

config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class Config(object):
1717
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
1818

1919
ADMINS = ['[email protected]']
20-
20+
LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT')
2121
GOOGLE_APPLICATION_CREDENTIALS = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS')
2222
POSTS_PER_PAGE = 3
2323
LANGUAGES = ['en', 'es']
2424
ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL')
25+

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ google-cloud-core==0.29.1
2222
google-cloud-translate==1.3.3
2323
googleapis-common-protos==1.5.6
2424
guess-language-spirit==0.5.3
25+
gunicorn==19.9.0
2526
idna==2.8
2627
itsdangerous==0.24
2728
Jinja2==2.10
2829
Mako==1.0.7
2930
MarkupSafe==1.0
3031
protobuf==3.6.1
32+
psycopg2==2.7.7
3133
pyasn1==0.4.5
3234
pyasn1-modules==0.2.4
3335
PyJWT==1.7.1

0 commit comments

Comments
 (0)