Files
notifications-admin/app/status/views/healthcheck.py
Leo Hemsted 89c7a87af2 use http healthcheck
prevents traffic being routed to apps that haven't warmed up yet
2019-05-17 14:50:36 +01:00

24 lines
845 B
Python

from flask import current_app, jsonify, request
from notifications_python_client.errors import HTTPError
from app import status_api_client, version
from app.status import status
@status.route('/_status', methods=['GET'])
def show_status():
if request.args.get('elb', None) or request.args.get('simple', None):
return jsonify(status="ok"), 200
else:
try:
api_status = status_api_client.get_status()
except HTTPError as e:
current_app.logger.exception("API failed to respond")
return jsonify(status="error", message=str(e.message)), 500
return jsonify(
status="ok",
api=api_status,
travis_commit=version.__travis_commit__,
travis_build_number=version.__travis_job_number__,
build_time=version.__time__), 200