[#306] cmd/node: Switch health status on boot and shutdown

Implement HealthChecker on node app structure. Set health status to ONLINE
after node boot. Set health status to OFFLINE on shutdown.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-13 16:36:41 +03:00 committed by Alex Vanin
parent 44a0fb5a69
commit df3746fa68
4 changed files with 20 additions and 0 deletions

View file

@ -41,6 +41,7 @@ func initPrivateService(c *cfg) {
privSvc := privateSvc.New(
privateSvc.WithKey(c.key),
privateSvc.WithAllowedKeys(keys),
privateSvc.WithHealthChecker(c),
)
var (
@ -65,3 +66,11 @@ func initPrivateService(c *cfg) {
fatalOnErr(c.cfgPrivateService.server.Serve(lis))
}))
}
func (c *cfg) setHealthStatus(st private.HealthStatus) {
c.healthStatus.Store(int32(st))
}
func (c *cfg) HealthStatus() private.HealthStatus {
return private.HealthStatus(c.healthStatus.Load())
}