Merge branch '1.0'

This commit is contained in:
Matthias Radestock committed 2015-07-03 14:18:46 +01:00
commit 8b0089565f
6 files changed
+16 -9

No files matched your search

+8 -1
View File
@@ -2,6 +2,7 @@ package net
import ( import (
"fmt" "fmt"
"math"
"net" "net"
"time" "time"
) )
@@ -10,11 +11,17 @@ const (
sleepTime = 100 * time.Millisecond sleepTime = 100 * time.Millisecond
) )
// Wait `wait` seconds for an interface to come up. Pass zero to check once
// and return immediately, or a negative value to wait indefinitely.
func EnsureInterface(ifaceName string, wait int) (iface *net.Interface, err error) { func EnsureInterface(ifaceName string, wait int) (iface *net.Interface, err error) {
if iface, err = findInterface(ifaceName); err == nil || wait == 0 { if iface, err = findInterface(ifaceName); err == nil || wait == 0 {
return return
} }
for i := time.Duration(wait) * time.Second / sleepTime; err != nil && i > 0; i-- { i := int64(math.MaxInt64)
if wait > 0 {
i = int64(time.Duration(wait) * time.Second / sleepTime)
}
for ; err != nil && i > 0; i-- {
time.Sleep(sleepTime) time.Sleep(sleepTime)
iface, err = findInterface(ifaceName) iface, err = findInterface(ifaceName)
} }
+1 -1
View File
@@ -3,4 +3,4 @@ MAINTAINER Weaveworks Inc <help@weave.works>
WORKDIR /home/weave WORKDIR /home/weave
ADD ./weavedns /home/weave/ ADD ./weavedns /home/weave/
EXPOSE 53/udp EXPOSE 53/udp
ENTRYPOINT ["/home/weave/weavedns", "-wait", "20"] ENTRYPOINT ["/home/weave/weavedns"]
+1 -1
View File
@@ -46,7 +46,7 @@ func main() {
flag.StringVar(&ifaceName, "iface", "", "name of interface to use for multicast") flag.StringVar(&ifaceName, "iface", "", "name of interface to use for multicast")
flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "path to Docker API socket") flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "path to Docker API socket")
flag.StringVar(&domain, "domain", weavedns.DefaultLocalDomain, "local domain (ie, 'weave.local.')") flag.StringVar(&domain, "domain", weavedns.DefaultLocalDomain, "local domain (ie, 'weave.local.')")
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up") flag.IntVar(&wait, "wait", -1, "number of seconds to wait for interfaces to come up (0=don't wait, -1=wait forever)")
flag.IntVar(&dnsPort, "dnsport", weavedns.DefaultServerPort, "port to listen to DNS requests") flag.IntVar(&dnsPort, "dnsport", weavedns.DefaultServerPort, "port to listen to DNS requests")
flag.StringVar(&httpIfaceName, "httpiface", "", "interface on which to listen for HTTP requests (defaults to empty string which listens on all interfaces)") flag.StringVar(&httpIfaceName, "httpiface", "", "interface on which to listen for HTTP requests (defaults to empty string which listens on all interfaces)")
flag.IntVar(&httpPort, "httpport", weavedns.DefaultHTTPPort, "port to listen to HTTP requests") flag.IntVar(&httpPort, "httpport", weavedns.DefaultHTTPPort, "port to listen to HTTP requests")
+1 -1
View File
@@ -2,4 +2,4 @@ FROM scratch
MAINTAINER Weaveworks Inc <help@weave.works> MAINTAINER Weaveworks Inc <help@weave.works>
WORKDIR /home/weave WORKDIR /home/weave
ADD ./weaver /home/weave/ ADD ./weaver /home/weave/
ENTRYPOINT ["/home/weave/weaver", "-wait", "20"] ENTRYPOINT ["/home/weave/weaver"]
+1 -1
View File
@@ -58,7 +58,7 @@ func main() {
flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC of interface)") flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC of interface)")
flag.StringVar(&nickName, "nickname", "", "nickname of peer (defaults to hostname)") flag.StringVar(&nickName, "nickname", "", "nickname of peer (defaults to hostname)")
flag.StringVar(&password, "password", "", "network password") flag.StringVar(&password, "password", "", "network password")
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up (0 = don't wait)") flag.IntVar(&wait, "wait", -1, "number of seconds to wait for interface to come up (0=don't wait, -1=wait forever)")
flag.BoolVar(&debug, "debug", false, "enable debug logging") flag.BoolVar(&debug, "debug", false, "enable debug logging")
flag.BoolVar(&pktdebug, "pktdebug", false, "enable per-packet debug logging") flag.BoolVar(&pktdebug, "pktdebug", false, "enable per-packet 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")
+4 -4
View File
@@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"math"
"os" "os"
"os/exec" "os/exec"
"os/signal" "os/signal"
@@ -17,20 +18,19 @@ func main() {
} }
args := os.Args[1:] args := os.Args[1:]
signalWait := 20 signalWait := time.Duration(math.MaxInt64)
if args[0] == "-s" { if args[0] == "-s" {
signalWait = 0 signalWait = 0
args = args[1:] args = args[1:]
} }
interfaceWait := 20 - signalWait
usr2 := make(chan os.Signal) usr2 := make(chan os.Signal)
signal.Notify(usr2, syscall.SIGUSR2) signal.Notify(usr2, syscall.SIGUSR2)
select { select {
case <-usr2: case <-usr2:
case <-time.After(time.Duration(signalWait) * time.Second): case <-time.After(signalWait):
} }
_, err := net.EnsureInterface("ethwe", interfaceWait) _, err := net.EnsureInterface("ethwe", -1)
checkErr(err) checkErr(err)
binary, err := exec.LookPath(args[0]) binary, err := exec.LookPath(args[0])