mirror of
https://github.com/moby/moby.git
synced 2026-08-03 22:51:03 +00:00
cmd/dockerd: windows: move setting PIDFile location to setPlatformOptions
Unlike Linux, which uses fixed locations as default, the Windows daemon uses paths relative to the data-root as defaults for storing both the PIDFile, and the daemon configuration file (daemon.json). The data-root is configurable both through command-line options (`--data-root`), and through the daemon configuration file (daemon.json). This patch moves Windows- specific config handling to config-related code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/log"
|
||||
@@ -23,8 +24,14 @@ func getDefaultDaemonConfigFile() string {
|
||||
}
|
||||
|
||||
// setPlatformOptions applies platform-specific CLI configuration options.
|
||||
// There is none on windows, so this is a no-op.
|
||||
func setPlatformOptions(conf *config.Config) error {
|
||||
if conf.Pidfile == "" {
|
||||
// On Windows, the pid-file location is relative to the daemon's data-root,
|
||||
// which is configurable, so we cannot use a fixed default location.
|
||||
// Instead, we set the location here, after we parsed command-line flags
|
||||
// and loaded the configuration file (if any).
|
||||
conf.Pidfile = filepath.Join(conf.Root, "docker.pid")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,12 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Microsoft/go-winio/pkg/etwlogrus"
|
||||
"github.com/containerd/log"
|
||||
)
|
||||
|
||||
func runDaemon(opts *daemonOptions) error {
|
||||
// Windows specific settings as these are not defaulted.
|
||||
if opts.daemonConfig.Pidfile == "" {
|
||||
opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid")
|
||||
}
|
||||
cli, err := NewDaemonCli(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user