From 3f5e7ae0bdf13dcee4caaa05905a2ef2b89b93c3 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Tue, 15 Dec 2015 17:14:13 +0000 Subject: [PATCH] Added healthcheck page - used in ELB healthchecks --- app/__init__.py | 3 +++ app/main/views/healthcheck.py | 7 +++++++ app/status/__init__.py | 5 +++++ app/status/views/__init__.py | 0 app/status/views/healthcheck.py | 10 ++++++++++ scripts/aws_stop_app.sh | 1 + 6 files changed, 26 insertions(+) create mode 100644 app/main/views/healthcheck.py create mode 100644 app/status/__init__.py create mode 100644 app/status/views/__init__.py create mode 100644 app/status/views/healthcheck.py diff --git a/app/__init__.py b/app/__init__.py index 1c12d0066..5e8d047c4 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -19,6 +19,9 @@ def create_app(config_name): from .main import main as main_blueprint application.register_blueprint(main_blueprint) + from .status import status as status_blueprint + application.register_blueprint(status_blueprint) + return application diff --git a/app/main/views/healthcheck.py b/app/main/views/healthcheck.py new file mode 100644 index 000000000..d4ab49ca7 --- /dev/null +++ b/app/main/views/healthcheck.py @@ -0,0 +1,7 @@ +from flask import jsonify +from .. import main + + +@main.route('/', methods=['GET']) +def get_index(): + return jsonify(result="hello world"), 200 diff --git a/app/status/__init__.py b/app/status/__init__.py new file mode 100644 index 000000000..fcbc7cece --- /dev/null +++ b/app/status/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +status = Blueprint('status', __name__) + +from app.status.views import healthcheck diff --git a/app/status/views/__init__.py b/app/status/views/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/app/status/views/healthcheck.py b/app/status/views/healthcheck.py new file mode 100644 index 000000000..ef7a6ee69 --- /dev/null +++ b/app/status/views/healthcheck.py @@ -0,0 +1,10 @@ +from flask import jsonify + +from app.status import status + + +@status.route('/_status') +def status(): + return jsonify( + status="ok", + ), 200 diff --git a/scripts/aws_stop_app.sh b/scripts/aws_stop_app.sh index 6a45877f5..9dc15fbd8 100755 --- a/scripts/aws_stop_app.sh +++ b/scripts/aws_stop_app.sh @@ -2,3 +2,4 @@ echo "Stopping application" cd ~/notifications-api/; +sudo service notifications-api stop \ No newline at end of file