Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/check accessible api #175

Merged
merged 3 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bothub/health/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

CHECK_ACCESSIBLE_API_URL = config(
'CHECK_ACCESSIBLE_API_URL',
default='http://localhost/api/repositories/')
default=None)


def check_database_connection(**kwargs):
Expand All @@ -27,10 +27,16 @@ def check_database_connection(**kwargs):
return True


def check_accessible_api(**kwargs):
def check_accessible_api(request, **kwargs):
import requests
logger.info('requesting {}'.format(CHECK_ACCESSIBLE_API_URL))
response = requests.get(CHECK_ACCESSIBLE_API_URL)
if CHECK_ACCESSIBLE_API_URL:
response = requests.get(CHECK_ACCESSIBLE_API_URL)
else:
url = 'http://{}/api/repositories/'.format(
request.META.get('HTTP_HOST'))
logger.info('requesting to {}'.format(url))
response = requests.get(url)
logger.info('{} response status code {}'.format(
CHECK_ACCESSIBLE_API_URL,
response.status_code))
Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ python manage.py collectstatic --noinput

GUNICORN_LOG_FILE="/var/log/gunicorn.log"
touch ${GUNICORN_LOG_FILE}
gunicorn bothub.wsgi -c docker/gunicorn.conf.py --log-file ${GUNICORN_LOG_FILE} --log-level debug
gunicorn bothub.wsgi -c docker/gunicorn.conf.py --log-file ${GUNICORN_LOG_FILE} --log-level debug --capture-output

mkdir -p /run/nginx/
nginx
Expand Down