소스 검색

Remove pkg/systemd

Signed-off-by: Antonio Murdaca <runcom@linux.com>
Antonio Murdaca 10 년 전
부모
커밋
931645c460
3개의 변경된 파일36개의 추가작업 그리고 77개의 파일을 삭제
  1. 36 3
      api/server/server_unix.go
  2. 0 40
      pkg/systemd/listendfd.go
  3. 0 34
      pkg/systemd/sd_notify.go

+ 36 - 3
api/server/server_unix.go

@@ -10,8 +10,10 @@ import (
 
 
 	"github.com/docker/docker/daemon"
 	"github.com/docker/docker/daemon"
 	"github.com/docker/docker/pkg/sockets"
 	"github.com/docker/docker/pkg/sockets"
-	"github.com/docker/docker/pkg/systemd"
 	"github.com/docker/libnetwork/portallocator"
 	"github.com/docker/libnetwork/portallocator"
+
+	systemdActivation "github.com/coreos/go-systemd/activation"
+	systemdDaemon "github.com/coreos/go-systemd/daemon"
 )
 )
 
 
 // newServer sets up the required serverClosers and does protocol specific checking.
 // newServer sets up the required serverClosers and does protocol specific checking.
@@ -22,7 +24,7 @@ func (s *Server) newServer(proto, addr string) ([]serverCloser, error) {
 	)
 	)
 	switch proto {
 	switch proto {
 	case "fd":
 	case "fd":
-		ls, err = systemd.ListenFD(addr)
+		ls, err = listenFD(addr)
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
@@ -65,7 +67,7 @@ func (s *Server) AcceptConnections(d *daemon.Daemon) {
 	// Tell the init daemon we are accepting requests
 	// Tell the init daemon we are accepting requests
 	s.daemon = d
 	s.daemon = d
 	s.registerSubRouter()
 	s.registerSubRouter()
-	go systemd.SdNotify("READY=1")
+	go systemdDaemon.SdNotify("READY=1")
 	// close the lock so the listeners start accepting connections
 	// close the lock so the listeners start accepting connections
 	select {
 	select {
 	case <-s.start:
 	case <-s.start:
@@ -110,3 +112,34 @@ func getContainersByNameDownlevel(w http.ResponseWriter, s *Server, namevar stri
 	}
 	}
 	return writeJSON(w, http.StatusOK, containerJSONRaw)
 	return writeJSON(w, http.StatusOK, containerJSONRaw)
 }
 }
+
+// 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 := systemdActivation.Listeners(false)
+	if err != nil {
+		return nil, err
+	}
+
+	if listeners == nil || len(listeners) == 0 {
+		return nil, fmt.Errorf("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, fmt.Errorf("Too few socket activated files passed in")
+	}
+
+	if addr == "*" {
+		return listeners, nil
+	}
+
+	return []net.Listener{listeners[fdOffset]}, nil
+}

+ 0 - 40
pkg/systemd/listendfd.go

@@ -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
-}

+ 0 - 34
pkg/systemd/sd_notify.go

@@ -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
-}