23 lines
354 B
Go
23 lines
354 B
Go
|
package sdnotify
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func SdNotify(state string) error {
|
||
|
name := os.Getenv("NOTIFY_SOCKET")
|
||
|
if name == "" {
|
||
|
return SdNotifyNoSocket
|
||
|
}
|
||
|
|
||
|
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
|
||
|
}
|