mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Fixed up the health check page
This commit is contained in:
11
app.py
11
app.py
@@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from flask.ext.script import Manager, Server
|
from flask.ext.script import Manager, Server
|
||||||
from flask_migrate import Migrate, MigrateCommand
|
from app import create_app
|
||||||
from app import (create_app, get_app_version)
|
|
||||||
|
|
||||||
|
|
||||||
application = create_app(os.getenv('NOTIFICATIONS_ADMIN_ENVIRONMENT') or 'development')
|
application = create_app(os.getenv('NOTIFICATIONS_ADMIN_ENVIRONMENT') or 'development')
|
||||||
@@ -17,13 +16,5 @@ def list_routes():
|
|||||||
print("{:10} {}".format(", ".join(rule.methods - set(['OPTIONS', 'HEAD'])), rule.rule))
|
print("{:10} {}".format(", ".join(rule.methods - set(['OPTIONS', 'HEAD'])), rule.rule))
|
||||||
|
|
||||||
|
|
||||||
@manager.command
|
|
||||||
def app_version():
|
|
||||||
"""
|
|
||||||
Retrieve the version of the api.
|
|
||||||
"""
|
|
||||||
return get_app_version()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
manager.run()
|
manager.run()
|
||||||
|
|||||||
@@ -183,15 +183,3 @@ def register_errorhandlers(application):
|
|||||||
return useful_headers_after_request(resp)
|
return useful_headers_after_request(resp)
|
||||||
for errcode in [401, 404, 403, 500]:
|
for errcode in [401, 404, 403, 500]:
|
||||||
application.errorhandler(errcode)(render_error)
|
application.errorhandler(errcode)(render_error)
|
||||||
|
|
||||||
|
|
||||||
def get_app_version():
|
|
||||||
build = 'n/a'
|
|
||||||
build_time = "n/a"
|
|
||||||
try:
|
|
||||||
from app import version
|
|
||||||
build = version.__build__
|
|
||||||
build_time = version.__time__
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return build, build_time
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
|
|
||||||
|
from flask import request
|
||||||
|
|
||||||
|
from app import version
|
||||||
|
|
||||||
from app.status import status
|
from app.status import status
|
||||||
|
|
||||||
|
@status.route('/_status', methods=['GET'])
|
||||||
@status.route('/_status')
|
def show_status():
|
||||||
def status():
|
if request.args.get('elb', None):
|
||||||
from app import (get_app_version, status_api_client)
|
return jsonify(status="ok"), 200
|
||||||
api_status = 'n/a'
|
else:
|
||||||
try:
|
return jsonify(
|
||||||
api_status = status_api_client.get_status()
|
status="ok",
|
||||||
except:
|
travis_commit=version.__travis_commit__,
|
||||||
api_status = 'n/a'
|
travis_build_number=version.__travis_job_number__,
|
||||||
build, build_time = get_app_version()
|
build_time=version.__time__), 200
|
||||||
return jsonify(status="ok",
|
|
||||||
api_status=api_status,
|
|
||||||
api_build=build,
|
|
||||||
api_built_time=build_time), 200
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
__build__ = ""
|
__travis_commit__ = "dev"
|
||||||
__time__ = ""
|
__time__ = "dev"
|
||||||
|
__travis_job_number__ = "dev"
|
||||||
|
|||||||
7
scripts/update_version_file.sh
Executable file
7
scripts/update_version_file.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Update the version file of the project from the Travis build details
|
||||||
|
#
|
||||||
|
sed -i -e "s/__travis_commit__ =.*/__travis_commit__ = \"$TRAVIS_COMMIT\"/g" ./app/version.py
|
||||||
|
sed -i -e "s/__travis_job_number__ =.*/__travis_job_number__ = \"$TRAVIS_BUILD_NUMBER\"/g" ./app/version.py
|
||||||
|
sed -i -e "s/__time__ =.*/__time__ = \"$(date +%Y-%m-%d:%H:%M:%S)\"/g" ./app/version.py
|
||||||
Reference in New Issue
Block a user