mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #10515 from Prototik/fix-sd-notify
etcdmain: fix sd_notify for restricted environments
This commit is contained in:
commit
6da17cda18
@ -20,7 +20,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/daemon"
|
"github.com/coreos/go-systemd/daemon"
|
||||||
systemdutil "github.com/coreos/go-systemd/util"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,14 +47,7 @@ func Main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func notifySystemd(lg *zap.Logger) {
|
func notifySystemd(lg *zap.Logger) {
|
||||||
if !systemdutil.IsRunningSystemd() {
|
_, err := daemon.SdNotify(false, daemon.SdNotifyReady)
|
||||||
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")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if lg != nil {
|
if lg != nil {
|
||||||
lg.Error("failed to notify systemd for readiness", zap.Error(err))
|
lg.Error("failed to notify systemd for readiness", zap.Error(err))
|
||||||
@ -63,12 +55,4 @@ func notifySystemd(lg *zap.Logger) {
|
|||||||
plog.Errorf("failed to notify systemd for readiness: %v", err)
|
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?")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user