From 42c5cafd2f261adaea6a6036bde4c515ce8ab066 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Sun, 22 Jan 2017 13:50:33 -0800 Subject: [PATCH] Actually randomize the splay --- client/consul_template.go | 7 ++++++- scripts/install_consul.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client/consul_template.go b/client/consul_template.go index 4f30b229d95..6861c515907 100644 --- a/client/consul_template.go +++ b/client/consul_template.go @@ -2,6 +2,7 @@ package client import ( "fmt" + "math/rand" "os" "path/filepath" "strings" @@ -261,8 +262,12 @@ WAIT: if restart || len(signals) != 0 { if splay != 0 { + ns := splay.Nanoseconds() + offset := rand.Int63n(ns) + t := time.Duration(offset) + select { - case <-time.After(time.Duration(splay)): + case <-time.After(t): case <-tm.shutdownCh: return } diff --git a/scripts/install_consul.sh b/scripts/install_consul.sh index 9623e6288a1..5c4812dba77 100755 --- a/scripts/install_consul.sh +++ b/scripts/install_consul.sh @@ -2,7 +2,7 @@ set -ex -CONSUL_VERSION="0.7.0" +CONSUL_VERSION="0.7.2" CURDIR=`pwd` echo Fetching Consul...