github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/libcontainerd/remote_daemon_linux.go (about)

     1  package libcontainerd
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"syscall"
     7  	"time"
     8  
     9  	"github.com/docker/docker/pkg/system"
    10  )
    11  
    12  const (
    13  	sockFile      = "docker-containerd.sock"
    14  	debugSockFile = "docker-containerd-debug.sock"
    15  )
    16  
    17  func (r *remote) setDefaults() {
    18  	if r.GRPC.Address == "" {
    19  		r.GRPC.Address = filepath.Join(r.stateDir, sockFile)
    20  	}
    21  	if r.Debug.Address == "" {
    22  		r.Debug.Address = filepath.Join(r.stateDir, debugSockFile)
    23  	}
    24  	if r.Debug.Level == "" {
    25  		r.Debug.Level = "info"
    26  	}
    27  	if r.OOMScore == 0 {
    28  		r.OOMScore = -999
    29  	}
    30  	if r.snapshotter == "" {
    31  		r.snapshotter = "overlay"
    32  	}
    33  }
    34  
    35  func (r *remote) stopDaemon() {
    36  	// Ask the daemon to quit
    37  	syscall.Kill(r.daemonPid, syscall.SIGTERM)
    38  	// Wait up to 15secs for it to stop
    39  	for i := time.Duration(0); i < shutdownTimeout; i += time.Second {
    40  		if !system.IsProcessAlive(r.daemonPid) {
    41  			break
    42  		}
    43  		time.Sleep(time.Second)
    44  	}
    45  
    46  	if system.IsProcessAlive(r.daemonPid) {
    47  		r.logger.WithField("pid", r.daemonPid).Warn("daemon didn't stop within 15 secs, killing it")
    48  		syscall.Kill(r.daemonPid, syscall.SIGKILL)
    49  	}
    50  }
    51  
    52  func (r *remote) platformCleanup() {
    53  	os.Remove(filepath.Join(r.stateDir, sockFile))
    54  }