Add proxy info to './weave status' output
This commit is contained in:
1 parent
2be69634df
commit
7f62ba6ebe
3 files changed
+51
-12
No files matched your search
+11
-8
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"code.google.com/p/getopt"
|
||||
. "github.com/weaveworks/weave/common"
|
||||
@@ -10,21 +10,28 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
version = "(unreleased version)"
|
||||
defaultTarget = "unix:///var/run/docker.sock"
|
||||
defaultListen = ":12375"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var target, listen string
|
||||
var withDNS, withIPAM, debug bool
|
||||
var withDNS, withIPAM, debug, justVersion bool
|
||||
|
||||
getopt.BoolVarLong(&debug, "debug", 'd', "log debugging information")
|
||||
getopt.BoolVarLong(&justVersion, "version", 0, "print version and exit")
|
||||
getopt.StringVar(&target, 'H', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultTarget))
|
||||
getopt.StringVar(&listen, 'L', fmt.Sprintf("address on which to listen (default %s)", defaultListen))
|
||||
getopt.BoolVarLong(&withDNS, "with-dns", 'w', "instruct created containers to use weaveDNS as their nameserver")
|
||||
getopt.BoolVarLong(&withIPAM, "with-ipam", 'i', "automatically allocate addresses for containers without a WEAVE_CIDR")
|
||||
getopt.Parse()
|
||||
|
||||
if justVersion {
|
||||
fmt.Printf("weave proxy %s\n", version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if target == "" {
|
||||
target = defaultTarget
|
||||
}
|
||||
@@ -37,19 +44,15 @@ func main() {
|
||||
InitDefaultLogging(true)
|
||||
}
|
||||
|
||||
p, err := proxy.NewProxy(target, withDNS, withIPAM)
|
||||
p, err := proxy.NewProxy(version, target, listen, withDNS, withIPAM)
|
||||
if err != nil {
|
||||
Error.Fatalf("Could not start proxy: %s", err)
|
||||
}
|
||||
s := &http.Server{
|
||||
Addr: listen,
|
||||
Handler: p,
|
||||
}
|
||||
|
||||
Info.Printf("Listening on %s", listen)
|
||||
Info.Printf("Proxying %s", target)
|
||||
|
||||
if err := s.ListenAndServe(); err != nil {
|
||||
if err := p.ListenAndServe(); err != nil {
|
||||
Error.Fatalf("Could not listen on %s: %s", listen, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user