Wait for plugin status via unix socket

This commit is contained in:
Bryan Boreham committed 2016-02-01 10:11:46 +00:00
1 parent 78f2d82984
commit 0a4b3a04ba
2 files changed
+16

No files matched your search

+15
View File
@@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"net"
"net/http"
"os"
"os/signal"
"syscall"
@@ -77,6 +78,11 @@ func run(dockerClient *docker.Client, address, meshAddress string, noMulticastRo
defer meshListener.Close()
}
statusListener, err := weavenet.ListenUnixSocket("/home/weave/status.sock")
if err != nil {
return err
}
go serveStatus(statusListener)
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, os.Kill, syscall.SIGTERM)
@@ -114,3 +120,12 @@ func listenAndServe(dockerClient *docker.Client, address string, noMulticastRout
return listener, nil
}
func serveStatus(listener net.Listener) {
server := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "ok")
})}
if err := server.Serve(listener); err != nil {
Log.Fatalf("ListenAndServeStatus failed: %s", err)
}
}
+1
View File
@@ -1724,6 +1724,7 @@ launch_plugin_if_not_running() {
$PLUGIN_IMAGE "$@") ; then
return 1
fi
wait_for_status $PLUGIN_CONTAINER_NAME http_call_unix $PLUGIN_CONTAINER_NAME status.sock
util_op create-plugin-network weave weavemesh
}