remote_daemon_linux.go 1.1 KB

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