From 0af8502c6d0b33e4ea951d0ffc7a6046f8d1a96f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 22 May 2012 15:24:28 -0400 Subject: [PATCH] Dirt-simple heartbeat page for use by AWS load balancers --- djangoapps/heartbeat/__init__.py | 0 djangoapps/heartbeat/urls.py | 5 +++++ djangoapps/heartbeat/views.py | 12 ++++++++++++ urls.py | 1 + 4 files changed, 18 insertions(+) create mode 100644 djangoapps/heartbeat/__init__.py create mode 100644 djangoapps/heartbeat/urls.py create mode 100644 djangoapps/heartbeat/views.py diff --git a/djangoapps/heartbeat/__init__.py b/djangoapps/heartbeat/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/djangoapps/heartbeat/urls.py b/djangoapps/heartbeat/urls.py new file mode 100644 index 0000000000..f8047eb00a --- /dev/null +++ b/djangoapps/heartbeat/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('', + url(r'^$', 'heartbeat.views.heartbeat', name='heartbeat'), +) diff --git a/djangoapps/heartbeat/views.py b/djangoapps/heartbeat/views.py new file mode 100644 index 0000000000..879c9e6016 --- /dev/null +++ b/djangoapps/heartbeat/views.py @@ -0,0 +1,12 @@ +import json +from datetime import datetime +from django.http import HttpResponse + +def heartbeat(request): + """ + Simple view that a loadbalancer can check to verify that the app is up + """ + output = { + 'date': datetime.now().isoformat() + } + return HttpResponse(json.dumps(output, indent=4)) diff --git a/urls.py b/urls.py index e33dd39ec6..bd53c6a380 100644 --- a/urls.py +++ b/urls.py @@ -67,6 +67,7 @@ if settings.COURSEWARE_ENABLED: url(r'^edit_circuit/(?P[^/]*)$', 'circuit.views.edit_circuit'), url(r'^save_circuit/(?P[^/]*)$', 'circuit.views.save_circuit'), url(r'^calculate$', 'util.views.calculate'), + url(r'^heartbeat$', include('heartbeat.urls')), ) if settings.ENABLE_MULTICOURSE: