Files
notifications-api/app/status/healthcheck.py
Athanasios Voutsadakis 9888ba3d4e Add http health-check for the api app
Also rename the 'elb' argument to 'simple' to be more descriptive.

The healthcheck is going to issue requests to `/_status?simple=true`
just to check that gunicorn is up and running - we don't need to go all
the way to the database, as this would have adverse impact when api is
under load.
2018-03-28 17:19:02 +01:00

29 lines
754 B
Python

from flask import (
jsonify,
Blueprint,
request
)
from app import db, version
status = Blueprint('status', __name__)
@status.route('/_status', methods=['GET', 'POST'])
def show_status():
if request.args.get('simple', None):
return jsonify(status="ok"), 200
else:
return jsonify(
status="ok", # This should be considered part of the public API
travis_commit=version.__travis_commit__,
travis_build_number=version.__travis_job_number__,
build_time=version.__time__,
db_version=get_db_version()), 200
def get_db_version():
query = 'SELECT version_num FROM alembic_version'
full_name = db.session.execute(query).fetchone()[0]
return full_name