Schedule periodic scan before starting initial scan

This commit is contained in:
Deluan 2021-05-08 19:19:31 -04:00
parent 71c2ed9922
commit 8419a2a5d1
1 changed files with 6 additions and 6 deletions

View File

@ -117,15 +117,9 @@ 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)
@ -133,6 +127,12 @@ func schedulePeriodicScan(schedule string) {
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)) {