remote_daemon_unix.go 1.2 KB

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