Skip to content

Commit

Permalink
Schedule periodic scan before starting initial scan
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed May 8, 2021
1 parent 71c2ed9 commit 8419a2a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/root.go
Expand Up @@ -117,22 +117,22 @@ func startSignaler() (func() error, func(err error)) {
}

func schedulePeriodicScan(schedule string) {
time.Sleep(2 * time.Second) // Wait 2 seconds before the first scan
scanner := GetScanner()
scheduler := GetScheduler()

log.Info("Executing initial scan")
if err := scanner.RescanAll(context.Background(), false); err != nil {
log.Error("Error executing initial scan", err)
}

log.Info("Scheduling periodic scan", "schedule", schedule)
err := scheduler.Add(schedule, func() {
_ = scanner.RescanAll(context.Background(), false)
})
if err != nil {
log.Error("Error scheduling periodic scan", err)
}

time.Sleep(2 * time.Second) // Wait 2 seconds before the initial scan
log.Info("Executing initial scan")
if err := scanner.RescanAll(context.Background(), false); err != nil {
log.Error("Error executing initial scan", err)
}
}

func startScheduler() (func() error, func(err error)) {
Expand Down

0 comments on commit 8419a2a

Please sign in to comment.