diff options
-rw-r--r-- | nslcd_systemd/nslcd_systemd.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/nslcd_systemd/nslcd_systemd.go b/nslcd_systemd/nslcd_systemd.go index 8bc4931..1073249 100644 --- a/nslcd_systemd/nslcd_systemd.go +++ b/nslcd_systemd/nslcd_systemd.go @@ -39,9 +39,9 @@ import ( "os/signal" "sync" - "golang.org/x/sys/unix" "git.lukeshu.com/go/libnslcd/nslcd_server" "git.lukeshu.com/go/libsystemd/sd_daemon" + "golang.org/x/sys/unix" ) type Backend interface { @@ -105,7 +105,7 @@ func Main(backend Backend) uint8 { err = backend.Init() if err != nil { sd_daemon.Log.Err(fmt.Sprintf("Could not initialize backend: %v", err)) - sd_daemon.Notify(0, false, "STOPPING=1", nil) + sd_daemon.Notification{State: "STOPPING=1"}.Send(false) return sd_daemon.EXIT_FAILURE } defer backend.Close() @@ -113,7 +113,7 @@ func Main(backend Backend) uint8 { socket, err := get_socket() if err != nil { sd_daemon.Log.Err(fmt.Sprintf("%v", err)) - sd_daemon.Notify(0, false, "STOPPING=1", nil) + sd_daemon.Notification{State: "STOPPING=1"}.Send(false) return sd_daemon.EXIT_NOTRUNNING } defer socket.Close() @@ -133,8 +133,8 @@ func Main(backend Backend) uint8 { var wg sync.WaitGroup defer wg.Wait() - defer sd_daemon.Notify(0, false, "STOPPING=1", nil) - sd_daemon.Notify(0, false, "READY=1", nil) + defer sd_daemon.Notification{State: "STOPPING=1"}.Send(false) + sd_daemon.Notification{State: "READY=1"}.Send(false) for { select { case sig := <-sigs: @@ -143,13 +143,13 @@ func Main(backend Backend) uint8 { sd_daemon.Log.Notice("Received SIGTERM, shutting down") return sd_daemon.EXIT_SUCCESS case unix.SIGHUP: - sd_daemon.Notify(0, false, "RELOADING=1", nil) + sd_daemon.Notification{State: "RELOADING=1"}.Send(false) err := backend.Reload() if err != nil { sd_daemon.Log.Notice(fmt.Sprintf("Could not reload backend: %s", err.Error())) return sd_daemon.EXIT_NOTRUNNING } - sd_daemon.Notify(0, false, "READY=1", nil) + sd_daemon.Notification{State: "READY=1"}.Send(false) } case conn := <-sock: wg.Add(1) |