Rejoin join nodes automatically

This adds a --rejoin setting for rejoining
cluter nodes automatically when gone.
This commit is contained in:
kaiyou
2020-05-21 17:51:21 +02:00
parent 62d9c44c11
commit da04afe24b
2 changed files with 10 additions and 0 deletions

View File

@ -50,6 +50,12 @@ func main() {
Logger: logrus.StandardLogger(),
}
// Prepare the rejoin timer
rejoin := make(<-chan time.Time)
if config.Rejoin > 0 {
rejoin = time.Tick(time.Duration(1000000000 * config.Rejoin))
}
// Join the cluster
cluster.Update(localNode)
nodec := cluster.Members() // avoid deadlocks by starting before join
@ -96,6 +102,9 @@ func main() {
logrus.Info("announcing new routes...")
localNode.Routes = routes
cluster.Update(localNode)
case <-rejoin:
logrus.Debug("rejoining missing join nodes...")
cluster.Join(config.Join)
case <-incomingSigs:
logrus.Info("terminating...")
cluster.Leave()