chore(standby_server): still sleep for the first time

This commit is contained in:
Yicheng Qin 2014-05-15 23:18:59 -04:00
parent e5ce4fca2e
commit 716496ec42

View File

@ -168,10 +168,10 @@ func (s *StandbyServer) redirectRequests(w http.ResponseWriter, r *http.Request)
uhttp.Redirect(leader.ClientURL, w, r) uhttp.Redirect(leader.ClientURL, w, r)
} }
// monitorCluster assumes that the machine has tried to join the cluster and
// failed, so it waits for the interval at the beginning.
func (s *StandbyServer) monitorCluster() { func (s *StandbyServer) monitorCluster() {
first := true
for { for {
if !first {
timer := time.NewTimer(time.Duration(int64(s.syncInterval * float64(time.Second)))) timer := time.NewTimer(time.Duration(int64(s.syncInterval * float64(time.Second))))
defer timer.Stop() defer timer.Stop()
select { select {
@ -179,8 +179,6 @@ func (s *StandbyServer) monitorCluster() {
return return
case <-timer.C: case <-timer.C:
} }
}
first = false
if err := s.syncCluster(nil); err != nil { if err := s.syncCluster(nil); err != nil {
log.Warnf("fail syncing cluster(%v): %v", s.Cluster(), err) log.Warnf("fail syncing cluster(%v): %v", s.Cluster(), err)