File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -305,14 +305,16 @@ def backup(req: HttpRequest) -> HttpResponse:
305305
306306
307307@csrf_exempt
308- def mongo_health (req : HttpRequest ) -> HttpResponse :
309- if req .method == "GET" :
310- if not engine .is_mongodb_running ():
311- return HttpResponseBadRequest ("MongoDB is down" )
308+ def mongo_health (req : HttpRequest ) -> JsonResponse :
309+ if req .method != "GET" :
310+ return JsonResponse ({"status" : "Method Not Allowed" }, status = 405 )
311+ try :
312+ if engine .is_mongodb_running ():
313+ return JsonResponse ({"status" : "ok" }, status = 200 )
312314 else :
313- return HttpResponse ( " MongoDB is up" )
314- else :
315- return HttpResponseBadRequest ( "Invalid request method" )
315+ return JsonResponse ({ "status" : "error" , "message" : " MongoDB is down" }, status = 503 )
316+ except Exception as e :
317+ return JsonResponse ({ "status" : "error" , "message" : str ( e )}, status = 503 )
316318
317319
318320def get_urlpatterns ():
You can’t perform that action at this time.
0 commit comments