From 3ece1d6cd3e6f47a11b0a53008a9e1025597bd18 Mon Sep 17 00:00:00 2001 From: Olli Janatuinen Date: Sun, 8 Jul 2018 00:28:45 +0300 Subject: [PATCH] Use named pipe as default for swarmd on Windows Signed-off-by: Olli Janatuinen --- .../defaults/{defaults.go => defaults_unix.go} | 5 +++++ cmd/swarmd/defaults/defaults_windows.go | 12 ++++++++++++ cmd/swarmd/main.go | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) rename cmd/swarmd/defaults/{defaults.go => defaults_unix.go} (67%) create mode 100644 cmd/swarmd/defaults/defaults_windows.go diff --git a/cmd/swarmd/defaults/defaults.go b/cmd/swarmd/defaults/defaults_unix.go similarity index 67% rename from cmd/swarmd/defaults/defaults.go rename to cmd/swarmd/defaults/defaults_unix.go index b4fe9ade7c..7da63aa83e 100644 --- a/cmd/swarmd/defaults/defaults.go +++ b/cmd/swarmd/defaults/defaults_unix.go @@ -1,7 +1,12 @@ +// +build !windows + package defaults // ControlAPISocket is the default path where clients can contact the swarmd control API. var ControlAPISocket = "/var/run/swarmd.sock" +// EngineAddr is Docker default socket file on Linux +var EngineAddr = "unix:///var/run/docker.sock" + // StateDir is the default path to the swarmd state directory var StateDir = "/var/lib/swarmd" diff --git a/cmd/swarmd/defaults/defaults_windows.go b/cmd/swarmd/defaults/defaults_windows.go new file mode 100644 index 0000000000..00ebf9698f --- /dev/null +++ b/cmd/swarmd/defaults/defaults_windows.go @@ -0,0 +1,12 @@ +// +build windows + +package defaults + +// ControlAPISocket is the default path where clients can contact the swarmd control API. +var ControlAPISocket = "//./pipe/swarmd" + +// EngineAddr is Docker default named pipe on Windows +var EngineAddr = "npipe:////./pipe/docker_engine" + +// StateDir is the default path to the swarmd state directory +var StateDir = `C:\ProgramData\swarmd` diff --git a/cmd/swarmd/main.go b/cmd/swarmd/main.go index 604801cb35..60ffe81cb1 100644 --- a/cmd/swarmd/main.go +++ b/cmd/swarmd/main.go @@ -256,7 +256,7 @@ func init() { mainCmd.Flags().StringP("log-level", "l", "info", "Log level (options \"debug\", \"info\", \"warn\", \"error\", \"fatal\", \"panic\")") mainCmd.Flags().StringP("state-dir", "d", defaults.StateDir, "State directory") mainCmd.Flags().StringP("join-token", "", "", "Specifies the secret token required to join the cluster") - mainCmd.Flags().String("engine-addr", "unix:///var/run/docker.sock", "Address of engine instance of agent.") + mainCmd.Flags().String("engine-addr", defaults.EngineAddr, "Address of engine instance of agent.") mainCmd.Flags().String("containerd-addr", "", "Address of containerd instance of agent.") mainCmd.Flags().String("containerd-namespace", "swarmd", "Namespace to use when using containerd agent.") mainCmd.Flags().String("hostname", "", "Override reported agent hostname")