fix(scanner): spawn interval scans in a goroutine

this way, if the average scan takes longer than the tick interval, the ticker will be unblocked and scans won't stack on top of each other

related #63
This commit is contained in:
sentriz
2021-06-28 21:34:06 +01:00
parent 4109b5b66c
commit c0ca6aaf03

View File

@@ -271,9 +271,11 @@ func (s *Server) StartScanTicker(dur time.Duration) (FuncExecute, FuncInterrupt)
case <-done:
return nil
case <-ticker.C:
if err := s.scanner.Start(scanner.ScanOptions{}); err != nil {
log.Printf("error scanning: %v", err)
}
go func() {
if err := s.scanner.Start(scanner.ScanOptions{}); err != nil {
log.Printf("error scanning: %v", err)
}
}()
}
}
}