Change -wait from bool to int number of seconds to wait
This commit is contained in:
1 parent
5b93577054
commit
0d3eebb208
2 files changed
+6
-8
No files matched your search
+1
-1
@@ -3,4 +3,4 @@ MAINTAINER Zettio weave@zett.io
|
||||
WORKDIR /home/weave
|
||||
ADD ./weaver /home/weave/
|
||||
CMD []
|
||||
ENTRYPOINT ["/home/weave/weaver", "-iface", "ethwe", "-wait"]
|
||||
ENTRYPOINT ["/home/weave/weaver", "-iface", "ethwe", "-wait", "5"]
|
||||
+5
-7
@@ -18,15 +18,13 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func ensureInterface(ifaceName string, wait bool) (iface *net.Interface, err error) {
|
||||
func ensureInterface(ifaceName string, wait int) (iface *net.Interface, err error) {
|
||||
iface, err = findInterface(ifaceName)
|
||||
if err == nil || !wait {
|
||||
if err == nil || wait == 0 {
|
||||
return
|
||||
}
|
||||
log.Println("Waiting for interface", ifaceName, "to come up")
|
||||
count := 0
|
||||
for err != nil && count < 5 {
|
||||
count += 1
|
||||
for ; err != nil && wait > 0; wait -= 1 {
|
||||
time.Sleep(1 * time.Second)
|
||||
iface, err = findInterface(ifaceName)
|
||||
}
|
||||
@@ -65,7 +63,7 @@ func main() {
|
||||
ifaceName string
|
||||
routerName string
|
||||
password string
|
||||
wait bool
|
||||
wait int
|
||||
debug bool
|
||||
prof string
|
||||
peers []string
|
||||
@@ -76,7 +74,7 @@ func main() {
|
||||
flag.StringVar(&ifaceName, "iface", "", "name of interface to read from")
|
||||
flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)")
|
||||
flag.StringVar(&password, "password", "", "network password")
|
||||
flag.BoolVar(&wait, "wait", false, "wait for interface to be created and come up")
|
||||
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up")
|
||||
flag.BoolVar(&debug, "debug", false, "enable debug logging")
|
||||
flag.StringVar(&prof, "profile", "", "enable profiling and write profiles to given path")
|
||||
flag.IntVar(&connLimit, "connlimit", 10, "connection limit (defaults to 10, set to 0 for unlimited)")
|
||||
|
||||
Reference in new issue
Block a user