mirror of https://github.com/docker/docs.git
Add a random delay to avoid synchronized registration at swarm join.
Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
parent
9dc6ce8d0f
commit
36ca8ff63f
|
@ -1,6 +1,7 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
|
@ -48,6 +49,12 @@ func join(c *cli.Context) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// add a random delay [0,hb) at start to avoid synchronized registration
|
||||
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
|
||||
delay := time.Duration(r.Int63n(int64(hb)))
|
||||
log.Infof("Add a random delay %s to avoid synchronized registration", delay)
|
||||
time.Sleep(delay)
|
||||
|
||||
for {
|
||||
log.WithFields(log.Fields{"addr": addr, "discovery": dflag}).Infof("Registering on the discovery service every %s...", hb)
|
||||
if err := d.Register(addr); err != nil {
|
||||
|
|
Loading…
Reference in New Issue