mirror of
https://github.com/rclone/rclone.git
synced 2024-12-03 05:45:24 +01:00
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
|
|
}
|