github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/libcontainerd/supervisor/remote_daemon_linux.go (about) 1 package supervisor // import "github.com/docker/docker/libcontainerd/supervisor" 2 3 import ( 4 "os" 5 "path/filepath" 6 "syscall" 7 "time" 8 9 "github.com/containerd/containerd/defaults" 10 "github.com/docker/docker/pkg/system" 11 ) 12 13 const ( 14 sockFile = "containerd.sock" 15 debugSockFile = "containerd-debug.sock" 16 ) 17 18 func (r *remote) setDefaults() { 19 if r.GRPC.Address == "" { 20 r.GRPC.Address = filepath.Join(r.stateDir, sockFile) 21 } 22 if r.GRPC.MaxRecvMsgSize == 0 { 23 r.GRPC.MaxRecvMsgSize = defaults.DefaultMaxRecvMsgSize 24 } 25 if r.GRPC.MaxSendMsgSize == 0 { 26 r.GRPC.MaxSendMsgSize = defaults.DefaultMaxSendMsgSize 27 } 28 if r.Debug.Address == "" { 29 r.Debug.Address = filepath.Join(r.stateDir, debugSockFile) 30 } 31 if r.OOMScore == 0 { 32 r.OOMScore = -999 33 } 34 35 for key, conf := range r.pluginConfs.Plugins { 36 if conf == nil { 37 r.DisabledPlugins = append(r.DisabledPlugins, key) 38 delete(r.pluginConfs.Plugins, key) 39 } 40 } 41 } 42 43 func (r *remote) stopDaemon() { 44 // Ask the daemon to quit 45 syscall.Kill(r.daemonPid, syscall.SIGTERM) 46 // Wait up to 15secs for it to stop 47 for i := time.Duration(0); i < shutdownTimeout; i += time.Second { 48 if !system.IsProcessAlive(r.daemonPid) { 49 break 50 } 51 time.Sleep(time.Second) 52 } 53 54 if system.IsProcessAlive(r.daemonPid) { 55 r.logger.WithField("pid", r.daemonPid).Warn("daemon didn't stop within 15 secs, killing it") 56 syscall.Kill(r.daemonPid, syscall.SIGKILL) 57 } 58 } 59 60 func (r *remote) killDaemon() { 61 // Try to get a stack trace 62 syscall.Kill(r.daemonPid, syscall.SIGUSR1) 63 <-time.After(100 * time.Millisecond) 64 system.KillProcess(r.daemonPid) 65 } 66 67 func (r *remote) platformCleanup() { 68 os.Remove(filepath.Join(r.stateDir, sockFile)) 69 }