From 3c33eab35e34a7ca84f1363a7ea19c5a1e685fcd Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Tue, 2 May 2017 13:29:56 +0200 Subject: [PATCH] Fix systemd watchdog feature Commit coreos/go-systemd@0c088e introduce cleaning environment. First usage of sdnotify (for type=notify) was clearing NOTIFY_SOCKET environment variable. sdnotify in watchdog was unable to ping back. Fix #1353 --- cmd/traefik/traefik.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index 3c2b5c53e..6c5911e38 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -244,22 +244,25 @@ func run(traefikConfiguration *server.TraefikConfiguration) { svr := server.NewServer(globalConfiguration) svr.Start() defer svr.Close() - sent, err := daemon.SdNotify(true, "READY=1") + sent, err := daemon.SdNotify(false, "READY=1") if !sent && err != nil { log.Error("Fail to notify", err) } - t, err := daemon.SdWatchdogEnabled(true) + t, err := daemon.SdWatchdogEnabled(false) if err != nil { log.Error("Problem with watchdog", err) } else if t != 0 { // Send a ping each half time given t = t / 2 - go func(interval time.Duration) { - tick := time.Tick(interval) + log.Info("Watchdog activated with timer each ", t) + safe.Go(func() { + tick := time.Tick(t) 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() log.Info("Shutting down")