udhos / jazigo

Jazigo is a tool written in Go for retrieving configuration for multiple devices, similar to rancid, fetchconfig, oxidized, Sweet.
MIT License
215 stars 27 forks source link

When the scan interval is modified, the scan loop should proceed #5

Open udhos opened 6 years ago

udhos commented 6 years ago

Need to interrupt time.Sleep(sleep) below:

func scanLoop(jaz *app) {
        for {
                jaz.logf("scanLoop: starting")
                opt := jaz.options.Get()
                begin := time.Now()
                dev.Scan(jaz.table, jaz.table.ListDevices(), jaz.logger, opt, jaz.requestChan)
                elap := time.Since(begin)
                sleep := opt.ScanInterval - elap
                if sleep < 1 {
                        sleep = 0
                }
                jaz.logf("scanLoop: sleeping for %s (target: scanInterval=%s)", sleep, opt.ScanInterval)
                time.Sleep(sleep)
        }
}