forked from GithubBackups/healthchecks
Lightweight 'server status' API endpoint, to be used by external load balancers
This commit is contained in:
parent
0f07fadc71
commit
c073cb0b3a
@ -12,4 +12,5 @@ urlpatterns = [
|
|||||||
name="hc-api-bounce"),
|
name="hc-api-bounce"),
|
||||||
url(r'^badge/([\w-]+)/([\w-]{8})/([\w-]+).svg$', views.badge,
|
url(r'^badge/([\w-]+)/([\w-]{8})/([\w-]+).svg$', views.badge,
|
||||||
name="hc-badge"),
|
name="hc-badge"),
|
||||||
|
url(r'^api/v1/status/$', views.status),
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from datetime import timedelta as td
|
from datetime import timedelta as td
|
||||||
|
|
||||||
|
from django.db import connection
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from django.http import (HttpResponse, HttpResponseForbidden,
|
from django.http import (HttpResponse, HttpResponseForbidden,
|
||||||
HttpResponseNotFound, JsonResponse)
|
HttpResponseNotFound, JsonResponse)
|
||||||
@ -185,3 +186,11 @@ def bounce(request, code):
|
|||||||
notification.save()
|
notification.save()
|
||||||
|
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
||||||
|
|
||||||
|
def status(request):
|
||||||
|
with connection.cursor() as c:
|
||||||
|
c.execute("SELECT 1")
|
||||||
|
c.fetchone()
|
||||||
|
|
||||||
|
return HttpResponse("OK")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user