Skip to content

Commit

Permalink
Update install.yaml to use /live for liveness check
Browse files Browse the repository at this point in the history
Also, inline health handler function for consistent style.
  • Loading branch information
enocom committed Feb 23, 2018
1 parent e8fe86d commit 97ff665
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ spec:
value: "8000"
livenessProbe:
httpGet:
path: /healthz
path: /live
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
Expand Down Expand Up @@ -288,4 +288,4 @@ subjects:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: agones-controller
name: agones-controller
36 changes: 17 additions & 19 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,23 @@ func main() {
logrus.WithError(err).Fatal("could not run webhook server")
}
}()
go startHealthCheck(health)
go func() {
logrus.Info("Starting health check...")
srv := &http.Server{
Addr: ":8080",
Handler: health,
}
defer srv.Close() // nolint: errcheck

if err := srv.ListenAndServe(); err != nil {
if err == http.ErrServerClosed {
logrus.WithError(err).Info("health check: http server closed")
} else {
err := errors.Wrap(err, "Could not listen on :8080")
runtime.HandleError(logrus.WithError(err), err)
}
}
}()

err = c.Run(2, stop)
if err != nil {
Expand All @@ -150,21 +166,3 @@ func main() {

logrus.Info("Shut down gameserver controller")
}

func startHealthCheck(h healthcheck.Handler) {
logrus.Info("Starting health check...")
srv := &http.Server{
Addr: ":8080",
Handler: h,
}
defer srv.Close() // nolint: errcheck

if err := srv.ListenAndServe(); err != nil {
if err == http.ErrServerClosed {
logrus.WithError(err).Info("health check: http server closed")
} else {
err := errors.Wrap(err, "Could not listen on :8080")
runtime.HandleError(logrus.WithError(err), err)
}
}
}

0 comments on commit 97ff665

Please sign in to comment.