mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Vendor coreos/go-systemd/daemon
Signed-off-by: Antonio Murdaca <runcom@linux.com>
This commit is contained in:
parent
ad5355151c
commit
61c9f4db41
1 changed files with 31 additions and 0 deletions
31
vendor/src/github.com/coreos/go-systemd/daemon/sdnotify.go
vendored
Normal file
31
vendor/src/github.com/coreos/go-systemd/daemon/sdnotify.go
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// Code forked from Docker project
|
||||||
|
package daemon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var SdNotifyNoSocket = errors.New("No socket")
|
||||||
|
|
||||||
|
// SdNotify sends a message to the init daemon. It is common to ignore the error.
|
||||||
|
func SdNotify(state string) error {
|
||||||
|
socketAddr := &net.UnixAddr{
|
||||||
|
Name: os.Getenv("NOTIFY_SOCKET"),
|
||||||
|
Net: "unixgram",
|
||||||
|
}
|
||||||
|
|
||||||
|
if socketAddr.Name == "" {
|
||||||
|
return SdNotifyNoSocket
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
_, err = conn.Write([]byte(state))
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue