Skip to content

Commit

Permalink
fix Cron
Browse files Browse the repository at this point in the history
  • Loading branch information
delaosa committed Apr 9, 2020
1 parent d08d09b commit 861eef5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cmd/podsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,22 @@ func main() {
c := cron.New(cron.WithChain(cron.SkipIfStillRunning(nil)))

for _, feed := range cfg.Feeds {
_feed := feed
if feed.CronSchedule == "" {
feed.CronSchedule = fmt.Sprintf("@every %s", feed.UpdatePeriod.String())
}

if _, err = c.AddFunc(feed.CronSchedule, func() {
log.Debugf("adding %q to update queue", feed.URL)
updates <- feed
if _, err = c.AddFunc(_feed.CronSchedule, func() {
log.Debugf("adding %q to update queue", _feed.URL)
updates <- _feed
}); err != nil {
log.WithError(err).Fatalf("can't create cron task for feed: %s", feed.ID)
log.WithError(err).Fatalf("can't create cron task for feed: %s", _feed.ID)
}

log.Debugf("-> %s (update '%s')", feed.URL, feed.CronSchedule)
log.Debugf("-> %s (update '%s')", _feed.URL, feed.CronSchedule)

// Perform initial update after CLI restart
updates <- feed
updates <- _feed
}

c.Start()
Expand Down

0 comments on commit 861eef5

Please sign in to comment.