CheckMonitor runs forever and runs the first check immediately

This commit is contained in:
Armon Dadgar 2014-01-20 16:46:01 -10:00
parent a4201255df
commit 9e63d1fa32

View File

@ -55,13 +55,17 @@ func (c *CheckMonitor) Stop() {
// run is invoked by a goroutine to run until Stop() is called // run is invoked by a goroutine to run until Stop() is called
func (c *CheckMonitor) run() { func (c *CheckMonitor) run() {
next := time.After(0)
for {
select { select {
case <-time.After(c.Interval): case <-next:
c.check() c.check()
next = time.After(c.Interval)
case <-c.stopCh: case <-c.stopCh:
return return
} }
} }
}
// check is invoked periodically to perform the script check // check is invoked periodically to perform the script check
func (c *CheckMonitor) check() { func (c *CheckMonitor) check() {