18 lines
612 B
Python
18 lines
612 B
Python
from django.db import connection
|
|
from rest_framework.decorators import api_view, authentication_classes, permission_classes
|
|
from rest_framework.response import Response
|
|
|
|
|
|
@api_view(["GET"])
|
|
@authentication_classes([])
|
|
@permission_classes([])
|
|
def healthcheck(request):
|
|
"""Liveness + database reachability, for compose/nginx health probes."""
|
|
try:
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("SELECT 1")
|
|
database = "up"
|
|
except Exception: # pragma: no cover - reported, not raised
|
|
database = "down"
|
|
return Response({"status": "ok", "database": database})
|