eliminate misleading flag parsing error
The standard mflags error reporting produces s.t. like ``` flag provided but not defined: -p See '/home/weave/weaver --help'. ``` on stderr. This is misleading since the program name is container local, so not something the user actually invoked. Fixes #1321.
This commit is contained in:
1 parent
f399c3a888
commit
fd6d15e712
1 file changed
+8
@@ -87,7 +87,15 @@ func main() {
|
|||||||
mflag.IntVar(&dnsTTL, []string{"-dns-ttl"}, nameserver.DefaultTTL, "TTL for DNS request from our domain")
|
mflag.IntVar(&dnsTTL, []string{"-dns-ttl"}, nameserver.DefaultTTL, "TTL for DNS request from our domain")
|
||||||
mflag.DurationVar(&dnsClientTimeout, []string{"-dns-fallback-timeout"}, nameserver.DefaultClientTimeout, "timeout for fallback DNS requests")
|
mflag.DurationVar(&dnsClientTimeout, []string{"-dns-fallback-timeout"}, nameserver.DefaultClientTimeout, "timeout for fallback DNS requests")
|
||||||
|
|
||||||
|
// crude way of detecting that we probably have been started in a
|
||||||
|
// container, with `weave launch` --> suppress misleading paths in
|
||||||
|
// mflags error messages.
|
||||||
|
if os.Args[0] == "/home/weave/weaver" { // matches the Dockerfile ENTRYPOINT
|
||||||
|
os.Args[0] = "weave"
|
||||||
|
mflag.CommandLine.Init("weave", mflag.ExitOnError)
|
||||||
|
}
|
||||||
mflag.Parse()
|
mflag.Parse()
|
||||||
|
|
||||||
peers = mflag.Args()
|
peers = mflag.Args()
|
||||||
|
|
||||||
SetLogLevel(logLevel)
|
SetLogLevel(logLevel)
|
||||||
|
|||||||
Reference in new issue
Block a user