diff --git a/systemd/listendfd.go b/systemd/listendfd.go deleted file mode 100644 index 0fbc0a6..0000000 --- a/systemd/listendfd.go +++ /dev/null @@ -1,40 +0,0 @@ -package systemd - -import ( - "errors" - "net" - "strconv" - - "github.com/coreos/go-systemd/activation" -) - -// ListenFD returns the specified socket activated files as a slice of -// net.Listeners or all of the activated files if "*" is given. -func ListenFD(addr string) ([]net.Listener, error) { - // socket activation - listeners, err := activation.Listeners(false) - if err != nil { - return nil, err - } - - if listeners == nil || len(listeners) == 0 { - return nil, errors.New("No sockets found") - } - - // default to all fds just like unix:// and tcp:// - if addr == "" { - addr = "*" - } - - fdNum, _ := strconv.Atoi(addr) - fdOffset := fdNum - 3 - if (addr != "*") && (len(listeners) < int(fdOffset)+1) { - return nil, errors.New("Too few socket activated files passed in") - } - - if addr == "*" { - return listeners, nil - } - - return []net.Listener{listeners[fdOffset]}, nil -} diff --git a/systemd/sd_notify.go b/systemd/sd_notify.go deleted file mode 100644 index bb864bb..0000000 --- a/systemd/sd_notify.go +++ /dev/null @@ -1,34 +0,0 @@ -package systemd - -import ( - "errors" - "net" - "os" -) - -// ErrSdNotifyNoSocket is an error returned if no socket was specified. -var ErrSdNotifyNoSocket = errors.New("No socket") - -// SdNotify sends a message to the init daemon. It is common to ignore the return value. -func SdNotify(state string) error { - socketAddr := &net.UnixAddr{ - Name: os.Getenv("NOTIFY_SOCKET"), - Net: "unixgram", - } - - if socketAddr.Name == "" { - return ErrSdNotifyNoSocket - } - - conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr) - if err != nil { - return err - } - - _, err = conn.Write([]byte(state)) - if err != nil { - return err - } - - return nil -}