daemon_windows.go 2.4 KB

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