github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/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 32 for key, conf := range r.pluginConfs.Plugins { 33 if conf == nil { 34 r.DisabledPlugins = append(r.DisabledPlugins, key) 35 delete(r.pluginConfs.Plugins, key) 36 } 37 } 38 } 39 40 func (r *remote) stopDaemon() { 41 // Ask the daemon to quit 42 syscall.Kill(r.daemonPid, syscall.SIGTERM) 43 // Wait up to 15secs for it to stop 44 for i := time.Duration(0); i < shutdownTimeout; i += time.Second { 45 if !system.IsProcessAlive(r.daemonPid) { 46 break 47 } 48 time.Sleep(time.Second) 49 } 50 51 if system.IsProcessAlive(r.daemonPid) { 52 r.logger.WithField("pid", r.daemonPid).Warn("daemon didn't stop within 15 secs, killing it") 53 syscall.Kill(r.daemonPid, syscall.SIGKILL) 54 } 55 } 56 57 func (r *remote) killDaemon() { 58 // Try to get a stack trace 59 syscall.Kill(r.daemonPid, syscall.SIGUSR1) 60 <-time.After(100 * time.Millisecond) 61 system.KillProcess(r.daemonPid) 62 } 63 64 func (r *remote) platformCleanup() { 65 os.Remove(filepath.Join(r.stateDir, sockFile)) 66 }