Add sd_notify to systemd after first sync

This commit is contained in:
Christian Goll
2021-12-06 11:03:45 +01:00
parent 2207ef84d9
commit 404490b756
3 changed files with 9 additions and 2 deletions

1
go.mod
View File

@@ -6,6 +6,7 @@ require (
github.com/brotherpowers/ipsubnet v0.0.0-20170914094241-30bc98f0a5b1
github.com/containers/image/v5 v5.7.0
github.com/containers/storage v1.30.0
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
github.com/creasty/defaults v1.5.2
github.com/fatih/color v1.13.0
github.com/google/uuid v1.1.2

View File

@@ -5,7 +5,7 @@ After=network-online.target
AssertFileIsExecutable=@BINDIR@/wwctl
[Service]
Type=forking
Type=notify
User=root
Group=root

View File

@@ -16,6 +16,7 @@ import (
"github.com/google/uuid"
"github.com/talos-systems/go-smbios/smbios"
"github.com/coreos/go-systemd/daemon"
"github.com/hpcng/warewulf/internal/pkg/pidfile"
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
@@ -149,9 +150,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(0)
}
}()
var finishedInitialSync bool = false
for {
updateSystem(conf.Ipaddr, conf.Warewulf.Port, wwid, tag, localUUID)
if !finishedInitialSync {
// ignore error and status here, as this wouldn't change anything
_, _ = daemon.SdNotify(false, daemon.SdNotifyReady)
finishedInitialSync = true
}
if conf.Warewulf.UpdateInterval > 0 {
time.Sleep(time.Duration(conf.Warewulf.UpdateInterval*1000) * time.Millisecond)