Skip to content

Commit

Permalink
added a readiness probe
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sharma <yashrsharma44@gmail.com>
  • Loading branch information
yashrsharma44 committed Mar 2, 2021
1 parent 4361243 commit 21a645b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
29 changes: 16 additions & 13 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,22 @@ func runReceive(
}

level.Debug(logger).Log("msg", "setting up http server")
srv := httpserver.New(logger, reg, comp, httpProbe,
httpserver.WithListen(httpBindAddr),
httpserver.WithGracePeriod(httpGracePeriod),
)
g.Add(func() error {
statusProber.Healthy()
err := srv.ListenAndServe()
return err
}, func(err error) {
statusProber.NotReady(err)
defer statusProber.NotHealthy(err)
srv.Shutdown(err)
})
{
srv := httpserver.New(logger, reg, comp, httpProbe,
httpserver.WithListen(httpBindAddr),
httpserver.WithGracePeriod(httpGracePeriod),
)
g.Add(func() error {
statusProber.Healthy()
err := srv.ListenAndServe()
return err
}, func(err error) {
statusProber.NotReady(err)
defer statusProber.NotHealthy(err)
srv.Shutdown(err)
})

}

level.Debug(logger).Log("msg", "setting up grpc server")
{
Expand Down
28 changes: 15 additions & 13 deletions cmd/thanos/receive_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,23 @@ func runReceiveRoute(
}

level.Debug(logger).Log("msg", "setting up http server")
srv := httpserver.New(logger, reg, comp, httpProbe,
httpserver.WithListen(httpBindAddr),
httpserver.WithGracePeriod(httpGracePeriod),
)
g.Add(func() error {
statusProber.Healthy()

return srv.ListenAndServe()
}, func(err error) {
statusProber.NotReady(err)
defer statusProber.NotHealthy(err)
{
srv := httpserver.New(logger, reg, comp, httpProbe,
httpserver.WithListen(httpBindAddr),
httpserver.WithGracePeriod(httpGracePeriod),
)
g.Add(func() error {
statusProber.Ready()
defer statusProber.Healthy()

srv.Shutdown(err)
})
return srv.ListenAndServe()
}, func(err error) {
statusProber.NotReady(err)
defer statusProber.NotHealthy(err)

srv.Shutdown(err)
})
}
level.Debug(logger).Log("msg", "setting up receive http handler")
{
g.Add(
Expand Down

0 comments on commit 21a645b

Please sign in to comment.