Merge pull request #1265 from hashicorp/remove-initial-delay

Remove initial delay of registering services with consul
This commit is contained in:
Diptanu Choudhury 2016-06-12 16:44:16 -07:00 committed by GitHub
commit 4dd0f951a4

View file

@ -752,14 +752,11 @@ func (c *Syncer) deregisterCheck(checkID string) error {
// Run triggers periodic syncing of services and checks with Consul. This is // Run triggers periodic syncing of services and checks with Consul. This is
// a long lived go-routine which is stopped during shutdown. // a long lived go-routine which is stopped during shutdown.
func (c *Syncer) Run() { func (c *Syncer) Run() {
d := initialSyncDelay + lib.RandomStagger(initialSyncBuffer-initialSyncDelay) sync := time.NewTimer(0)
sync := time.NewTimer(d)
c.logger.Printf("[DEBUG] consul.syncer: sleeping %v before first sync", d)
for { for {
select { select {
case <-sync.C: case <-sync.C:
d = syncInterval - lib.RandomStagger(syncInterval/syncJitter) d := syncInterval - lib.RandomStagger(syncInterval/syncJitter)
sync.Reset(d) sync.Reset(d)
if err := c.SyncServices(); err != nil { if err := c.SyncServices(); err != nil {