2016-02-19 22:42:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-03-21 11:57:53 +00:00
|
|
|
"path/filepath"
|
|
|
|
|
2016-04-23 00:16:14 +00:00
|
|
|
_ "github.com/docker/docker/autogen/winresources/dockerd"
|
2018-03-21 11:57:53 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2016-02-19 22:42:51 +00:00
|
|
|
)
|
2018-03-21 11:57:53 +00:00
|
|
|
|
|
|
|
func runDaemon(opts *daemonOptions) error {
|
|
|
|
daemonCli := NewDaemonCli()
|
|
|
|
|
|
|
|
// On Windows, this may be launching as a service or with an option to
|
|
|
|
// register the service.
|
|
|
|
stop, runAsService, err := initService(daemonCli)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if stop {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Windows specific settings as these are not defaulted.
|
|
|
|
if opts.configFile == "" {
|
|
|
|
opts.configFile = filepath.Join(opts.daemonConfig.Root, `config\daemon.json`)
|
|
|
|
}
|
|
|
|
if runAsService {
|
|
|
|
// If Windows SCM manages the service - no need for PID files
|
|
|
|
opts.daemonConfig.Pidfile = ""
|
|
|
|
} else if opts.daemonConfig.Pidfile == "" {
|
|
|
|
opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = daemonCli.start(opts)
|
|
|
|
notifyShutdown(err)
|
|
|
|
return err
|
|
|
|
}
|