diff --git a/cmd/apiary.go b/cmd/apiary.go index 3504f8f..47b609e 100644 --- a/cmd/apiary.go +++ b/cmd/apiary.go @@ -235,12 +235,17 @@ func ActionServe(c *cli.Context) error { ticker := time.NewTicker(timeout / 2) for { + // TODO: Consider using ctx with deadline to avoid healthcheck taking more time than ticker, + // which will result in being killed by watchdog. healthy := s.IsHealthy() select { case <-ticker.C: if healthy == nil { daemon.SdNotify(false, daemon.SdNotifyWatchdog) + continue } + // TODO: If unhealthy, should we retry healthcheck immediately, otherwise service will most likely get killed by watchdog. + loggers.rootLogger.Errorw("Store reported not healthy, might get killed by watchdog.", "err", healthy) case <-notifyCtx.Done(): loggers.rootLogger.Debugw("Notify context cancelled.") return