Skip to content

Commit

Permalink
readiness probe
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Nov 11, 2023
1 parent 5ada51c commit 063b591
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func Start(dbO *sqlx.DB) *fhr.Router {

// v1 API
{
r.Method("_health", v1.HealthGET)

r.POSTMethod("/api/v1/tokens/self/delete", v1.TokenSelfDeletePOST)

// Auth-free API endpoints (public data)
Expand Down
32 changes: 32 additions & 0 deletions app/v1/health.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v1

import (
"github.com/osuAkatsuki/akatsuki-api/app/peppy"
"github.com/osuAkatsuki/akatsuki-api/common"
)

type healthResponse struct {
common.ResponseBase
}

func HealthGET(md common.MethodData) common.CodeMessager {
var r healthResponse

err := peppy.R.Ping().Err()
if err != nil {
r.Code = 500
r.Message = "redis error"
return r
}

err = md.DB.Ping()
if err != nil {
r.Code = 500
r.Message = "database error"
return r
}

r.Code = 200
r.Message = "healthy"
return r
}
9 changes: 9 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ apps:
env:
- name: APP_COMPONENT
value: api
readinessProbe:
httpGet:
path: /_health
port: 80
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
resources:
limits:
cpu: 500m
Expand Down

0 comments on commit 063b591

Please sign in to comment.