1package main
2
3import (
4	"path/filepath"
5
6	_ "github.com/docker/docker/autogen/winresources/dockerd"
7	"github.com/sirupsen/logrus"
8)
9
10func runDaemon(opts *daemonOptions) error {
11	daemonCli := NewDaemonCli()
12
13	// On Windows, this may be launching as a service or with an option to
14	// register the service.
15	stop, runAsService, err := initService(daemonCli)
16	if err != nil {
17		logrus.Fatal(err)
18	}
19
20	if stop {
21		return nil
22	}
23
24	// Windows specific settings as these are not defaulted.
25	if opts.configFile == "" {
26		opts.configFile = filepath.Join(opts.daemonConfig.Root, `config\daemon.json`)
27	}
28	if runAsService {
29		// If Windows SCM manages the service - no need for PID files
30		opts.daemonConfig.Pidfile = ""
31	} else if opts.daemonConfig.Pidfile == "" {
32		opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid")
33	}
34
35	err = daemonCli.start(opts)
36	notifyShutdown(err)
37	return err
38}
39