Skip to content

Commit

Permalink
Fix a few issues on healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rockychen-dpaw committed Oct 9, 2024
1 parent 89cf081 commit 279fb2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion authome/urls/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
admin_urls[0].insert(0,path('auth2status/<str:clusterid>', views.auth2_status,name="auth2_status"))
admin_urls[0].insert(1,path('liveness/<str:clusterid>/<str:serviceid>/<str:monitordate>.html', views.auth2_liveness,name="auth2_liveness"))
else:
admin_urls[0].insert(0,path('healthcheck', views.auth2_healthcheck,name="auth2_healthcheck"))
admin_urls[0].insert(0,path('healthcheck', views.auth2_status,name="auth2_status"))
admin_urls[0].insert(1,path('liveness/<str:serviceid>/<str:monitordate>.html', views.auth2_liveness,name="auth2_liveness"))

admin_urls[0].insert(0,path('authome/tools/apple/secretkey/renew', views.renew_apple_secretkey,name="renew_apple_secretkey"))
Expand Down
6 changes: 3 additions & 3 deletions authome/views/healthcheckviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def _auth2_cluster_status(request,clusterid):


def _auth2_status(request):
f = os.path.join(settings.AUTH2_MONITORING_DIR,"auth2","serverinfo.html")
f = os.path.join(settings.AUTH2_MONITORING_DIR,"auth2","standalone","serverinfo.html")
if os.path.exists(f):
return FileResponse(open(f,'rb'))
else:
return TemplateResponse(request,"authome/healthcheck_not_enabled.html",context={"message":"The healthcheck is not enabled for auth2 server".format(clusterid)})
return TemplateResponse(request,"authome/healthcheck_not_enabled.html",context={"message":"The healthcheck is not enabled for auth2 server"})

def _auth2_cluster_liveness(request,clusterid,serviceid,monitordate):
if clusterid == settings.AUTH2_CLUSTERID:
Expand All @@ -32,7 +32,7 @@ def _auth2_cluster_liveness(request,clusterid,serviceid,monitordate):
return HttpResponse(cache.get_auth2_liveness(clusterid,serviceid,monitordate),content_type="text/html")

def _auth2_liveness(request,serviceid,monitordate):
return FileResponse(open(os.path.join(settings.AUTH2_MONITORING_DIR,"auth2",serviceid,"{}.html".format(monitordate)),'rb'))
return FileResponse(open(os.path.join(settings.AUTH2_MONITORING_DIR,"auth2","standalone",serviceid,"{}.html".format(monitordate)),'rb'))

auth2_status = _auth2_cluster_status if settings.AUTH2_CLUSTER_ENABLED else _auth2_status
auth2_liveness = _auth2_cluster_liveness if settings.AUTH2_CLUSTER_ENABLED else _auth2_liveness

0 comments on commit 279fb2c

Please sign in to comment.