mirror of
https://github.com/jeremyd/ergo.git
synced 2026-04-26 15:40:00 -07:00
23
vendor/github.com/okzk/sdnotify/notify_linux.go
generated
vendored
Normal file
23
vendor/github.com/okzk/sdnotify/notify_linux.go
generated
vendored
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user