support systemd notifications

Fixes #1733
This commit is contained in:
Shivaram Lingamneni 2021-07-04 07:41:59 -04:00
parent c53df2dc88
commit 6f24082705
10 changed files with 123 additions and 2 deletions

23
vendor/github.com/okzk/sdnotify/notify_linux.go generated vendored Normal file
View file

@ -0,0 +1,23 @@
package sdnotify
import (
"net"
"os"
)
// SdNotify sends a specified string to the systemd notification socket.
func SdNotify(state string) error {
name := os.Getenv("NOTIFY_SOCKET")
if name == "" {
return ErrSdNotifyNoSocket
}
conn, err := net.DialUnix("unixgram", nil, &net.UnixAddr{Name: name, Net: "unixgram"})
if err != nil {
return err
}
defer conn.Close()
_, err = conn.Write([]byte(state))
return err
}