Skip to content

Commit

Permalink
Fix Gunicorn 20 error
Browse files Browse the repository at this point in the history
This fixes two errors, one where we were not importing HTTPerror
appopriately in tasks.py which led to the app crashing and a second
error introduced by upgrading gunicorn. Gunicorn was upgraded to version
20 from 19.9 which was a major version upgrade and introduced a breaking
change. The change is documented by this issue on the git repo benoitc/gunicorn#2159
it is related to removing an eval statement so we can no longer have
gunicorn call a function to create our app. We have gone with a solution
introduced in this issue, to call the create_app function and then
export a variable where this application is saved. We then call
this variable in our Procfile where we run our server using Gunicorn.

This should fix our issue for now, and if gunicorn fixes the issue
in the libarary then we could always revert but I think this should
work going forward.
  • Loading branch information
jrusso1020 committed Nov 10, 2019
1 parent 8350a38 commit b463c95
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Procfile
@@ -1,4 +1,4 @@
web: pipenv run gunicorn "app:create_app()" --workers 8 --log-file -
web: pipenv run gunicorn "app:bsafe" --workers 8 --log-file -
worker: pipenv run flask worker --threads 1
periodiq: pipenv run flask periodiq

2 changes: 1 addition & 1 deletion app/__init__.py
@@ -1 +1 @@
from .app import create_app
from .app import bsafe
2 changes: 2 additions & 0 deletions app/app.py
Expand Up @@ -38,3 +38,5 @@ def configure_logging(app):
logging.FileHandler(f"{app.config['LOG_FOLDER']}/log.log"),
logging.StreamHandler()
])

bsafe = create_app()
1 change: 1 addition & 0 deletions app/tasks.py
Expand Up @@ -17,6 +17,7 @@
import os
import datetime
import requests
from urllib.error import HTTPError
from periodiq import PeriodiqMiddleware, cron
from ergo_analytics import LoadElasticSearch
from ergo_analytics import DataFilterPipeline
Expand Down

0 comments on commit b463c95

Please sign in to comment.