cron.go 485 B

123456789101112131415161718192021
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package cron
  5. import (
  6. "fmt"
  7. "github.com/robfig/cron"
  8. "github.com/gogits/gogs/models"
  9. "github.com/gogits/gogs/modules/setting"
  10. )
  11. func NewCronContext() {
  12. c := cron.New()
  13. c.AddFunc("@every 1h", models.MirrorUpdate)
  14. c.AddFunc(fmt.Sprintf("@every %dm", setting.WebhookTaskInterval), models.DeliverHooks)
  15. c.Start()
  16. }