mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 10:10:08 -08: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
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue