Browse code

Windows: Calculate PID file after root

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/10/18 03:48:51
Showing 2 changed files
... ...
@@ -3,6 +3,8 @@ package main
3 3
 import (
4 4
 	"fmt"
5 5
 	"os"
6
+	"path/filepath"
7
+	"runtime"
6 8
 
7 9
 	"github.com/Sirupsen/logrus"
8 10
 	"github.com/docker/docker/cli"
... ...
@@ -61,6 +63,11 @@ func runDaemon(opts daemonOptions) error {
61 61
 
62 62
 	daemonCli := NewDaemonCli()
63 63
 
64
+	// On Windows, if there's no explicit pidfile set, set to under the daemon root
65
+	if runtime.GOOS == "windows" && opts.daemonConfig.Pidfile == "" {
66
+		opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid")
67
+	}
68
+
64 69
 	// On Windows, this may be launching as a service or with an option to
65 70
 	// register the service.
66 71
 	stop, err := initService(daemonCli)
... ...
@@ -2,14 +2,15 @@ package daemon
2 2
 
3 3
 import (
4 4
 	"os"
5
+	"path/filepath"
5 6
 
6 7
 	"github.com/docker/docker/api/types"
7 8
 	"github.com/spf13/pflag"
8 9
 )
9 10
 
10 11
 var (
11
-	defaultPidFile = os.Getenv("programdata") + string(os.PathSeparator) + "docker.pid"
12
-	defaultGraph   = os.Getenv("programdata") + string(os.PathSeparator) + "docker"
12
+	defaultPidFile string
13
+	defaultGraph   = filepath.Join(os.Getenv("programdata"), "docker")
13 14
 )
14 15
 
15 16
 // bridgeConfig stores all the bridge driver specific