diff --git a/README.md b/README.md index 22092da7..23748005 100644 --- a/README.md +++ b/README.md @@ -461,6 +461,21 @@ Any running application containers will permanently lose connectivity with the weave network and have to be restarted in order to re-connect. +### Reboots + +When a host reboots, docker's default behaviour is to restart any +containers that were running. Since weave relies on special network +configuration outside of the containers, the weave network will not +function in this state. + +To remedy this, stop and re-launch the weave container, and re-attach +the application containers with `weave attach`. + +For a more permanent solution, +[disable Docker's auto-restart feature](https://docs.docker.com/articles/host_integration/) +and create appropriate startup scripts to launch weave and run +application containers from your favourite process manager. + ## Installation with Boot2Docker If you are running Docker inside the Boot2Docker VM, e.g. because you diff --git a/weaver/Dockerfile b/weaver/Dockerfile index adf86d35..9baf50bb 100644 --- a/weaver/Dockerfile +++ b/weaver/Dockerfile @@ -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"] diff --git a/weaver/main.go b/weaver/main.go index 63bb60d1..3ca078db 100644 --- a/weaver/main.go +++ b/weaver/main.go @@ -18,17 +18,19 @@ 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") - for err != nil { + for ; err != nil && wait > 0; wait -= 1 { time.Sleep(1 * time.Second) iface, err = findInterface(ifaceName) } - log.Println("Interface", ifaceName, "is up") + if err == nil { + log.Println("Interface", ifaceName, "is up") + } return } @@ -47,6 +49,7 @@ func main() { log.SetPrefix(weave.Protocol + " ") log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds) + log.Println(os.Args) procs := runtime.NumCPU() // packet sniffing can block an OS thread, so we need one thread @@ -60,7 +63,7 @@ func main() { ifaceName string routerName string password string - wait bool + wait int debug bool prof string peers []string @@ -71,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 (defaults to 0, i.e. don't wait)") 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)")