Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Fix/_status #31

Merged
merged 3 commits into from
Jul 12, 2019
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Accept: application/vnd.schemaorg.ld+json # for JSON-LD format

[OpenAPI documentation available here.](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/uc-cdis/pidgin/master/openapi/swagger.yml)

The YAML file comtaining the OpenAPI documentation can be found in the `openapi` folder; see the README in that folder for more details.
The YAML file containing the OpenAPI documentation can be found in the `openapi` folder; see the README in that folder for more details.
1 change: 1 addition & 0 deletions deployment/uwsgi/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
config = app.config

config["API_URL"] = "http://peregrine-service/v0/submission/graphql/"
config["API_HEALTH_URL"] = "http://peregrine-service/_status"
application = app
16 changes: 14 additions & 2 deletions pidgin/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from cdislogging import get_logger
import flask
import json
import requests
Expand All @@ -23,6 +24,8 @@
},
}

logger = get_logger(__name__, log_level="info")


@app.route("/<path:object_id>")
def get_core_metadata(object_id):
Expand Down Expand Up @@ -59,6 +62,7 @@ def get_core_metadata(object_id):
404:
description: No core metadata was found for this object_id
"""
logger.info("Getting metadata for object_id: {}".format(object_id))
accept = flask.request.headers.get("Accept")
if accept == "x-bibtex":
return get_bibtex_metadata(object_id)
Expand Down Expand Up @@ -286,7 +290,15 @@ def health_check():
responses:
200:
description: Healthy
default:
description: Unhealthy
500:
description: Unhealthy (Peregrine not available)
"""
api_health_url = app.config.get("API_HEALTH_URL")
if not api_health_url:
raise PidginException("Pidgin is not configured with API_HEALTH_URL")
try:
requests.get(api_health_url)
except requests.exceptions.ConnectionError:
logger.error("Peregrine not available; returning unhealthy")
return "Unhealthy", 500
return "Healthy", 200
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cdislogging==1.0.0
Flask==1.0.2
requests==2.20.0
1 change: 1 addition & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pidgin.app import app

app.config["API_URL"] = "http://localhost/v0/submission/graphql/" # peregrine endpoint
app.config["API_HEALTH_URL"] = "http://localhost/_status"
app.run("127.0.0.1", 5000, debug=True)
3 changes: 0 additions & 3 deletions tests/system_test.py

This file was deleted.