Skip to content

Commit

Permalink
fix(scanner): spawn interval scans in a goroutine
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sentriz committed Jun 28, 2021
1 parent 4109b5b commit c0ca6aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/server.go
Expand Up @@ -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)
}
}()
}
}
}
Expand Down

0 comments on commit c0ca6aa

Please sign in to comment.