Implement weave launch --resume
This commit is contained in:
1 parent
5e03c0fe25
commit
4b758dd130
3 files changed
+10
-5
No files matched your search
+6
-1
@@ -151,6 +151,7 @@ func main() {
|
|||||||
config mesh.Config
|
config mesh.Config
|
||||||
networkConfig weave.NetworkConfig
|
networkConfig weave.NetworkConfig
|
||||||
protocolMinVersion int
|
protocolMinVersion int
|
||||||
|
resume bool
|
||||||
ifaceName string
|
ifaceName string
|
||||||
routerName string
|
routerName string
|
||||||
nickName string
|
nickName string
|
||||||
@@ -181,6 +182,7 @@ func main() {
|
|||||||
mflag.StringVar(&config.Host, []string{"-host"}, "", "router host")
|
mflag.StringVar(&config.Host, []string{"-host"}, "", "router host")
|
||||||
mflag.IntVar(&config.Port, []string{"#port", "-port"}, mesh.Port, "router port")
|
mflag.IntVar(&config.Port, []string{"#port", "-port"}, mesh.Port, "router port")
|
||||||
mflag.IntVar(&protocolMinVersion, []string{"-min-protocol-version"}, mesh.ProtocolMinVersion, "minimum weave protocol version")
|
mflag.IntVar(&protocolMinVersion, []string{"-min-protocol-version"}, mesh.ProtocolMinVersion, "minimum weave protocol version")
|
||||||
|
mflag.BoolVar(&resume, []string{"-resume"}, false, "resume connections to previous peers")
|
||||||
mflag.StringVar(&ifaceName, []string{"#iface", "-iface"}, "", "name of interface to capture/inject from (disabled if blank)")
|
mflag.StringVar(&ifaceName, []string{"#iface", "-iface"}, "", "name of interface to capture/inject from (disabled if blank)")
|
||||||
mflag.StringVar(&routerName, []string{"#name", "-name"}, "", "name of router (defaults to MAC of interface)")
|
mflag.StringVar(&routerName, []string{"#name", "-name"}, "", "name of router (defaults to MAC of interface)")
|
||||||
mflag.StringVar(&nickName, []string{"#nickname", "-nickname"}, "", "nickname of peer (defaults to hostname)")
|
mflag.StringVar(&nickName, []string{"#nickname", "-nickname"}, "", "nickname of peer (defaults to hostname)")
|
||||||
@@ -218,6 +220,9 @@ func main() {
|
|||||||
mflag.Parse()
|
mflag.Parse()
|
||||||
|
|
||||||
peers = mflag.Args()
|
peers = mflag.Args()
|
||||||
|
if resume && len(peers) > 0 {
|
||||||
|
Log.Fatalf("You must not specify an initial peer list in conjuction with --resume")
|
||||||
|
}
|
||||||
|
|
||||||
common.SetLogLevel(logLevel)
|
common.SetLogLevel(logLevel)
|
||||||
|
|
||||||
@@ -267,7 +272,7 @@ func main() {
|
|||||||
router := weave.NewNetworkRouter(config, networkConfig, name, nickName, overlay, db)
|
router := weave.NewNetworkRouter(config, networkConfig, name, nickName, overlay, db)
|
||||||
Log.Println("Our name is", router.Ourself)
|
Log.Println("Our name is", router.Ourself)
|
||||||
|
|
||||||
if peers, err = router.InitialPeers(peers); err != nil {
|
if peers, err = router.InitialPeers(resume, peers); err != nil {
|
||||||
Log.Fatal("Unable to get initial peer set: ", err)
|
Log.Fatal("Unable to get initial peer set: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -230,13 +230,13 @@ func (router *NetworkRouter) ForgetConnections(peers []string) {
|
|||||||
router.persistPeers()
|
router.persistPeers()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (router *NetworkRouter) InitialPeers(peers []string) ([]string, error) {
|
func (router *NetworkRouter) InitialPeers(resume bool, peers []string) ([]string, error) {
|
||||||
if _, err := os.Stat("restart.sentinel"); err == nil {
|
if _, err := os.Stat("restart.sentinel"); err == nil || resume {
|
||||||
var storedPeers []string
|
var storedPeers []string
|
||||||
if _, err := router.db.Load(peersIdent, &storedPeers); err != nil {
|
if _, err := router.db.Load(peersIdent, &storedPeers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Println("Restart detected - using persisted peer list:", storedPeers)
|
log.Println("Restart/resume detected - using persisted peer list:", storedPeers)
|
||||||
return storedPeers, nil
|
return storedPeers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ weave launch <same arguments as 'weave launch-router'>
|
|||||||
[--no-restart] [--ipalloc-init <mode>]
|
[--no-restart] [--ipalloc-init <mode>]
|
||||||
[--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]
|
[--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]
|
||||||
[--no-discovery] [--no-dns]
|
[--no-discovery] [--no-dns]
|
||||||
[--trusted-subnets <cidr>,...] <peer> ...
|
[--trusted-subnets <cidr>,...] [--resume] <peer> ...
|
||||||
launch-proxy [-H <endpoint>] [--without-dns] [--no-multicast-route]
|
launch-proxy [-H <endpoint>] [--without-dns] [--no-multicast-route]
|
||||||
[--log-level=debug|info|warning|error]
|
[--log-level=debug|info|warning|error]
|
||||||
[--no-rewrite-hosts] [--no-default-ipalloc] [--no-restart]
|
[--no-rewrite-hosts] [--no-default-ipalloc] [--no-restart]
|
||||||
|
|||||||
Reference in new issue
Block a user