Переглянути джерело

Move process functions to pkg/system

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Vincent Demeester 8 роки тому
батько
коміт
8c1ac81665

+ 9 - 10
libcontainerd/remote_unix.go

@@ -21,8 +21,7 @@ import (
 	"github.com/Sirupsen/logrus"
 	containerd "github.com/docker/containerd/api/grpc/types"
 	"github.com/docker/docker/pkg/locker"
-	sysinfo "github.com/docker/docker/pkg/system"
-	"github.com/docker/docker/utils"
+	"github.com/docker/docker/pkg/system"
 	"github.com/golang/protobuf/ptypes"
 	"github.com/golang/protobuf/ptypes/timestamp"
 	"golang.org/x/net/context"
@@ -81,7 +80,7 @@ func New(stateDir string, options ...RemoteOption) (_ Remote, err error) {
 		}
 	}
 
-	if err := sysinfo.MkdirAll(stateDir, 0700); err != nil {
+	if err := system.MkdirAll(stateDir, 0700); err != nil {
 		return nil, err
 	}
 
@@ -164,8 +163,8 @@ func (r *remote) handleConnectionChange() {
 			transientFailureCount++
 			if transientFailureCount >= maxConnectionRetryCount {
 				transientFailureCount = 0
-				if utils.IsProcessAlive(r.daemonPid) {
-					utils.KillProcess(r.daemonPid)
+				if system.IsProcessAlive(r.daemonPid) {
+					system.KillProcess(r.daemonPid)
 				}
 				<-r.daemonWaitCh
 				if err := r.runContainerdDaemon(); err != nil { //FIXME: Handle error
@@ -188,13 +187,13 @@ func (r *remote) Cleanup() {
 
 	// Wait up to 15secs for it to stop
 	for i := time.Duration(0); i < containerdShutdownTimeout; i += time.Second {
-		if !utils.IsProcessAlive(r.daemonPid) {
+		if !system.IsProcessAlive(r.daemonPid) {
 			break
 		}
 		time.Sleep(time.Second)
 	}
 
-	if utils.IsProcessAlive(r.daemonPid) {
+	if system.IsProcessAlive(r.daemonPid) {
 		logrus.Warnf("libcontainerd: containerd (%d) didn't stop within 15 secs, killing it\n", r.daemonPid)
 		syscall.Kill(r.daemonPid, syscall.SIGKILL)
 	}
@@ -354,7 +353,7 @@ func (r *remote) runContainerdDaemon() error {
 		if err != nil {
 			return err
 		}
-		if utils.IsProcessAlive(int(pid)) {
+		if system.IsProcessAlive(int(pid)) {
 			logrus.Infof("libcontainerd: previous instance of containerd still alive (%d)", pid)
 			r.daemonPid = int(pid)
 			return nil
@@ -417,11 +416,11 @@ func (r *remote) runContainerdDaemon() error {
 	}
 	logrus.Infof("libcontainerd: new containerd process, pid: %d", cmd.Process.Pid)
 	if err := setOOMScore(cmd.Process.Pid, r.oomScore); err != nil {
-		utils.KillProcess(cmd.Process.Pid)
+		system.KillProcess(cmd.Process.Pid)
 		return err
 	}
 	if _, err := f.WriteString(fmt.Sprintf("%d", cmd.Process.Pid)); err != nil {
-		utils.KillProcess(cmd.Process.Pid)
+		system.KillProcess(cmd.Process.Pid)
 		return err
 	}
 

+ 1 - 1
utils/process_unix.go → pkg/system/process_unix.go

@@ -1,6 +1,6 @@
 // +build linux freebsd solaris
 
-package utils
+package system
 
 import (
 	"syscall"

+ 1 - 1
utils/process_windows.go → pkg/system/process_windows.go

@@ -1,4 +1,4 @@
-package utils
+package system
 
 // IsProcessAlive returns true if process with a given pid is running.
 func IsProcessAlive(pid int) bool {