daemon_windows.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package main
  2. import (
  3. "context"
  4. "fmt"
  5. "net"
  6. "os"
  7. "path/filepath"
  8. "time"
  9. "github.com/docker/docker/daemon/config"
  10. "github.com/docker/docker/libcontainerd/supervisor"
  11. "github.com/docker/docker/pkg/system"
  12. "github.com/sirupsen/logrus"
  13. "golang.org/x/sys/windows"
  14. )
  15. func getDefaultDaemonConfigFile() (string, error) {
  16. return "", nil
  17. }
  18. // setDefaultUmask doesn't do anything on windows
  19. func setDefaultUmask() error {
  20. return nil
  21. }
  22. func getDaemonConfDir(root string) (string, error) {
  23. return filepath.Join(root, `\config`), nil
  24. }
  25. // preNotifySystem sends a message to the host when the API is active, but before the daemon is
  26. func preNotifySystem() {
  27. // start the service now to prevent timeouts waiting for daemon to start
  28. // but still (eventually) complete all requests that are sent after this
  29. if service != nil {
  30. err := service.started()
  31. if err != nil {
  32. logrus.Fatal(err)
  33. }
  34. }
  35. }
  36. // notifySystem sends a message to the host when the server is ready to be used
  37. func notifySystem() {
  38. }
  39. // notifyShutdown is called after the daemon shuts down but before the process exits.
  40. func notifyShutdown(err error) {
  41. if service != nil {
  42. if err != nil {
  43. logrus.Fatal(err)
  44. }
  45. service.stopped(err)
  46. }
  47. }
  48. func (cli *DaemonCli) getPlatformContainerdDaemonOpts() ([]supervisor.DaemonOpt, error) {
  49. return nil, nil
  50. }
  51. // setupConfigReloadTrap configures a Win32 event to reload the configuration.
  52. func (cli *DaemonCli) setupConfigReloadTrap() {
  53. go func() {
  54. sa := windows.SecurityAttributes{
  55. Length: 0,
  56. }
  57. event := "Global\\docker-daemon-config-" + fmt.Sprint(os.Getpid())
  58. ev, _ := windows.UTF16PtrFromString(event)
  59. if h, _ := windows.CreateEvent(&sa, 0, 0, ev); h != 0 {
  60. logrus.Debugf("Config reload - waiting signal at %s", event)
  61. for {
  62. windows.WaitForSingleObject(h, windows.INFINITE)
  63. cli.reloadConfig()
  64. }
  65. }
  66. }()
  67. }
  68. // getSwarmRunRoot gets the root directory for swarm to store runtime state
  69. // For example, the control socket
  70. func (cli *DaemonCli) getSwarmRunRoot() string {
  71. return ""
  72. }
  73. func allocateDaemonPort(addr string) error {
  74. return nil
  75. }
  76. func wrapListeners(proto string, ls []net.Listener) []net.Listener {
  77. return ls
  78. }
  79. func newCgroupParent(config *config.Config) string {
  80. return ""
  81. }
  82. func (cli *DaemonCli) initContainerD(_ context.Context) (func(time.Duration) error, error) {
  83. system.InitContainerdRuntime(cli.Config.Experimental, cli.Config.ContainerdAddr)
  84. return nil, nil
  85. }