Change -wait from bool to int number of seconds to wait

This commit is contained in:
Bryan Boreham committed 2014-09-22 16:48:55 +01:00
1 parent 5b93577054
commit 0d3eebb208
2 files changed
+6 -8

No files matched your search

+1 -1
View File
@@ -3,4 +3,4 @@ MAINTAINER Zettio weave@zett.io
WORKDIR /home/weave WORKDIR /home/weave
ADD ./weaver /home/weave/ ADD ./weaver /home/weave/
CMD [] CMD []
ENTRYPOINT ["/home/weave/weaver", "-iface", "ethwe", "-wait"] ENTRYPOINT ["/home/weave/weaver", "-iface", "ethwe", "-wait", "5"]
+5 -7
View File
@@ -18,15 +18,13 @@ import (
"time" "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) iface, err = findInterface(ifaceName)
if err == nil || !wait { if err == nil || wait == 0 {
return return
} }
log.Println("Waiting for interface", ifaceName, "to come up") log.Println("Waiting for interface", ifaceName, "to come up")
count := 0 for ; err != nil && wait > 0; wait -= 1 {
for err != nil && count < 5 {
count += 1
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
iface, err = findInterface(ifaceName) iface, err = findInterface(ifaceName)
} }
@@ -65,7 +63,7 @@ func main() {
ifaceName string ifaceName string
routerName string routerName string
password string password string
wait bool wait int
debug bool debug bool
prof string prof string
peers []string peers []string
@@ -76,7 +74,7 @@ func main() {
flag.StringVar(&ifaceName, "iface", "", "name of interface to read from") flag.StringVar(&ifaceName, "iface", "", "name of interface to read from")
flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)") flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)")
flag.StringVar(&password, "password", "", "network password") 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.BoolVar(&debug, "debug", false, "enable debug logging")
flag.StringVar(&prof, "profile", "", "enable profiling and write profiles to given path") 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)") flag.IntVar(&connLimit, "connlimit", 10, "connection limit (defaults to 10, set to 0 for unlimited)")