diff --git a/cmd/scraper/bootstrap/bootstrap.go b/cmd/scraper/bootstrap/bootstrap.go index 1d57a97..7978cac 100644 --- a/cmd/scraper/bootstrap/bootstrap.go +++ b/cmd/scraper/bootstrap/bootstrap.go @@ -100,20 +100,22 @@ func InitTEDScraper(config Config, mongoManager *mongo.ConnectionManager, appLog // start TED scraper job with error handling scheduler := schedule.NewCronScheduler(appLogger, mongoManager, noticeRepo) + + function := func() { + ctx := context.Background() + err := tedScraper.Run(ctx, nil, nil) + if err != nil { + appLogger.Error("Scheduled scraper run failed", map[string]interface{}{ + "error": err.Error(), + }) + // Don't exit - continue running for next scheduled execution + } else { + appLogger.Info("Scheduled scraper run completed successfully", map[string]interface{}{}) + } + } err := scheduler.AddJob(schedule.Job{ Name: "TED Scraper Job", - Func: func() { - ctx := context.Background() - err := tedScraper.Run(ctx, nil, nil) - if err != nil { - appLogger.Error("Scheduled scraper run failed", map[string]interface{}{ - "error": err.Error(), - }) - // Don't exit - continue running for next scheduled execution - } else { - appLogger.Info("Scheduled scraper run completed successfully", map[string]interface{}{}) - } - }, + Func: function, Expr: config.TED.ScrapingInterval, }) if err != nil {