Merge pull request #2960 from weaveworks/remove-proxy-status-sock
Remove proxy status.sock
This commit is contained in:
commit
e0088e0252
3 files changed
+9
-29
No files matched your search
+6
-2
@@ -258,9 +258,11 @@ func main() {
|
||||
|
||||
var waitReady common.WaitGroup
|
||||
|
||||
var proxy *weaveproxy.Proxy
|
||||
var err error
|
||||
if proxyConfig.Enabled {
|
||||
// Start Weave Proxy:
|
||||
proxy, err := weaveproxy.NewProxy(*proxyConfig)
|
||||
proxy, err = weaveproxy.NewProxy(*proxyConfig)
|
||||
if err != nil {
|
||||
Log.Fatalf("Could not start proxy: %s", err)
|
||||
}
|
||||
@@ -268,7 +270,6 @@ func main() {
|
||||
listeners := proxy.Listen()
|
||||
proxy.AttachExistingContainers()
|
||||
go proxy.Serve(listeners, waitReady.Add())
|
||||
go proxy.ListenAndServeStatus("/home/weave/status.sock")
|
||||
}
|
||||
|
||||
if pktdebug {
|
||||
@@ -441,6 +442,9 @@ func main() {
|
||||
HandleHTTP(muxRouter, version, router, allocator, defaultSubnet, ns, dnsserver, &waitReady)
|
||||
HandleHTTPPeer(muxRouter, allocator, discoveryEndpoint, token, name.String())
|
||||
muxRouter.Methods("GET").Path("/metrics").Handler(metricsHandler(router, allocator, ns, dnsserver))
|
||||
if proxy != nil {
|
||||
muxRouter.Methods("GET").Path("/proxyaddrs").HandlerFunc(proxy.StatusHTTP)
|
||||
}
|
||||
http.Handle("/", common.LoggingHTTPHandler(muxRouter))
|
||||
Log.Println("Listening for HTTP control messages on", httpAddr)
|
||||
go listenAndServeHTTP(httpAddr, nil)
|
||||
|
||||
@@ -310,17 +310,6 @@ func (proxy *Proxy) Serve(listeners []net.Listener, ready func()) {
|
||||
}
|
||||
}
|
||||
|
||||
func (proxy *Proxy) ListenAndServeStatus(socket string) {
|
||||
listener, err := weavenet.ListenUnixSocket(socket)
|
||||
if err != nil {
|
||||
Log.Fatalf("ListenAndServeStatus failed: %s", err)
|
||||
}
|
||||
handler := http.HandlerFunc(proxy.StatusHTTP)
|
||||
if err := (&http.Server{Handler: handler}).Serve(listener); err != nil {
|
||||
Log.Fatalf("ListenAndServeStatus failed: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (proxy *Proxy) StatusHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
for _, addr := range proxy.normalisedAddrs {
|
||||
fmt.Fprintln(w, addr)
|
||||
|
||||
@@ -661,19 +661,6 @@ http_call() {
|
||||
return $retval
|
||||
}
|
||||
|
||||
http_call_unix() {
|
||||
container="$1"
|
||||
socket="$2"
|
||||
http_verb="$3"
|
||||
url="$4"
|
||||
shift 4
|
||||
# NB: requires curl >= 7.40
|
||||
output=$(docker exec $container curl -s -S -X $http_verb --unix-socket $socket "$@" http:$url) || return 1
|
||||
# in some docker versions, `docker exec` does not fail when the executed command fails
|
||||
[ -n "$output" ] || return 1
|
||||
echo $output
|
||||
}
|
||||
|
||||
call_weave() {
|
||||
TMPERR=/tmp/call_weave_err_$$
|
||||
retval=0
|
||||
@@ -1166,10 +1153,10 @@ proxy_args() {
|
||||
}
|
||||
|
||||
proxy_addrs() {
|
||||
if addr="$(http_call_unix $CONTAINER_NAME status.sock GET /status 2>/dev/null)" ; then
|
||||
echo "$addr" | sed "s/0.0.0.0/$PROXY_HOST/g"
|
||||
if addr="$(call_weave GET /proxyaddrs)" ; then
|
||||
[ -n "$addr" ] || return 1
|
||||
echo "$addr" | sed "s/0.0.0.0/$PROXY_HOST/g" | tr '\n' ' '
|
||||
else
|
||||
echo "$CONTAINER_NAME container is not present. Have you launched it?" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user