Skip to content

Commit

Permalink
etcdmain: fix sd_notify for restricted environments
Browse files Browse the repository at this point in the history
Remove call to dumb IsRunningSystemd() as it doesn't check anything
  • Loading branch information
Sergey Shatunov committed Mar 2, 2019
1 parent 2c69559 commit fbf732d
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 fbf732d

Please sign in to comment.