Merge pull request #1525 from guilhem/fix-watchdog

Fix systemd watchdog feature
This commit is contained in:
Ludovic Fernandez 2017-05-03 15:25:15 +02:00 committed by GitHub
commit f621d7a2c4

View file

@ -244,22 +244,25 @@ func run(traefikConfiguration *server.TraefikConfiguration) {
svr := server.NewServer(globalConfiguration) svr := server.NewServer(globalConfiguration)
svr.Start() svr.Start()
defer svr.Close() defer svr.Close()
sent, err := daemon.SdNotify(true, "READY=1") sent, err := daemon.SdNotify(false, "READY=1")
if !sent && err != nil { if !sent && err != nil {
log.Error("Fail to notify", err) log.Error("Fail to notify", err)
} }
t, err := daemon.SdWatchdogEnabled(true) t, err := daemon.SdWatchdogEnabled(false)
if err != nil { if err != nil {
log.Error("Problem with watchdog", err) log.Error("Problem with watchdog", err)
} else if t != 0 { } else if t != 0 {
// Send a ping each half time given // Send a ping each half time given
t = t / 2 t = t / 2
go func(interval time.Duration) { log.Info("Watchdog activated with timer each ", t)
tick := time.Tick(interval) safe.Go(func() {
tick := time.Tick(t)
for range tick { for range tick {
daemon.SdNotify(true, "WATCHDOG=1") if ok, _ := daemon.SdNotify(false, "WATCHDOG=1"); !ok {
log.Error("Fail to tick watchdog")
} }
}(t) }
})
} }
svr.Wait() svr.Wait()
log.Info("Shutting down") log.Info("Shutting down")