Skip to content

Commit

Permalink
Merge pull request etcd-io#10515 from Prototik/fix-sd-notify
Browse files Browse the repository at this point in the history
etcdmain: fix sd_notify for restricted environments
  • Loading branch information
xiang90 authored Mar 8, 2019
2 parents 4dc9d8b + fbf732d commit 6da17cd
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions etcdmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"strings"

"github.com/coreos/go-systemd/daemon"
systemdutil "github.com/coreos/go-systemd/util"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -48,27 +47,12 @@ func Main() {
}

func notifySystemd(lg *zap.Logger) {
if !systemdutil.IsRunningSystemd() {
return
}

if lg != nil {
lg.Info("host was booted with systemd, sends READY=1 message to init daemon")
}
sent, err := daemon.SdNotify(false, "READY=1")
_, err := daemon.SdNotify(false, daemon.SdNotifyReady)
if err != nil {
if lg != nil {
lg.Error("failed to notify systemd for readiness", zap.Error(err))
} else {
plog.Errorf("failed to notify systemd for readiness: %v", err)
}
}

if !sent {
if lg != nil {
lg.Warn("forgot to set Type=notify in systemd service file?")
} else {
plog.Errorf("forgot to set Type=notify in systemd service file?")
}
}
}

0 comments on commit 6da17cd

Please sign in to comment.