github.com/moby/docker@v26.1.3+incompatible/cmd/dockerd/docker_windows.go (about) 1 package main 2 3 import ( 4 "io" 5 "path/filepath" 6 7 "github.com/Microsoft/go-winio/pkg/etwlogrus" 8 "github.com/containerd/log" 9 ) 10 11 func runDaemon(opts *daemonOptions) error { 12 daemonCli := NewDaemonCli() 13 14 // On Windows, this may be launching as a service or with an option to 15 // register the service. 16 stop, runAsService, err := initService(daemonCli) 17 if err != nil { 18 return err 19 } 20 21 if stop { 22 return nil 23 } 24 25 // Windows specific settings as these are not defaulted. 26 if opts.configFile == "" { 27 opts.configFile = filepath.Join(opts.daemonConfig.Root, "config", "daemon.json") 28 } 29 if runAsService { 30 // If Windows SCM manages the service - no need for PID files 31 opts.daemonConfig.Pidfile = "" 32 } else if opts.daemonConfig.Pidfile == "" { 33 opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid") 34 } 35 36 err = daemonCli.start(opts) 37 notifyShutdown(err) 38 return err 39 } 40 41 func initLogging(stdout, _ io.Writer) { 42 // Maybe there is a historic reason why on non-Windows, stderr is used 43 // for output. However, on Windows it makes no sense and there is no need. 44 log.L.Logger.SetOutput(stdout) 45 46 // Provider ID: {6996f090-c5de-5082-a81e-5841acc3a635} 47 // Hook isn't closed explicitly, as it will exist until process exit. 48 // GUID is generated based on name - see Microsoft/go-winio/tools/etw-provider-gen. 49 if hook, err := etwlogrus.NewHook("Moby"); err == nil { 50 log.L.Logger.AddHook(hook) 51 } 52 return 53 }