Add --proxy option to enable/disable proxy.

Weave Net initially had the ability to start a single component at a time with `launch-proxy` and `launch-router`.
This change enables this again via `--proxy=false` despite the merge of the proxy and the router.
Note that by default:
- `launch` passes `--proxy` which enables the proxy and keeps behaviour consistent with `launch` pre-merge,
- `weaver` defaults `--proxy` to `false` which disables the proxy and keeps behaviour consistent with `weaver` pre-merge (as it was `weaveproxy`'s responsibility).
This commit is contained in:
Marc CARRE authored and Bryan Boreham committed 2017-05-10 10:25:36 +00:00
1 parent 2c7693b2c5
commit 5cf973f03a
3 files changed
+16 -11

No files matched your search

+12 -9
View File
@@ -252,16 +252,18 @@ func main() {
}
config.ProtocolMinVersion = byte(protocolMinVersion)
// Start Weave Proxy:
proxy, err := weaveproxy.NewProxy(*proxyConfig)
if err != nil {
Log.Fatalf("Could not start proxy: %s", err)
if proxyConfig.Enabled {
// Start Weave Proxy:
proxy, err := weaveproxy.NewProxy(*proxyConfig)
if err != nil {
Log.Fatalf("Could not start proxy: %s", err)
}
defer proxy.Stop()
listeners := proxy.Listen()
proxy.AttachExistingContainers()
go proxy.Serve(listeners)
go proxy.ListenAndServeStatus("/home/weave/status.sock")
}
defer proxy.Stop()
listeners := proxy.Listen()
proxy.AttachExistingContainers()
go proxy.Serve(listeners)
go proxy.ListenAndServeStatus("/home/weave/status.sock")
if pktdebug {
networkConfig.PacketLogging = packetLogging{}
@@ -521,6 +523,7 @@ func configureProxy(version string, defaultDockerHost string) *weaveproxy.Config
DockerBridge: getenvOrDefault("DOCKER_BRIDGE", "docker0"),
DockerHost: defaultDockerHost,
}
mflag.BoolVar(&proxyConfig.Enabled, []string{"-proxy"}, false, "instruct Weave Net to start its Docker proxy")
mflagext.ListVar(&proxyConfig.ListenAddrs, []string{"H"}, nil, "addresses on which to listen")
mflag.StringVar(&proxyConfig.HostnameFromLabel, []string{"-hostname-from-label"}, "", "Key of container label from which to obtain the container's hostname")
mflag.StringVar(&proxyConfig.HostnameMatch, []string{"-hostname-match"}, "(.*)", "Regexp pattern to apply on container names (e.g. '^aws-[0-9]+-(.*)$')")