mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
make cron task configurable
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,27 +0,0 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cron
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
var c = New()
|
||||
|
||||
func NewCronContext() {
|
||||
c.AddFunc("Update mirrors", "@every 1h", models.MirrorUpdate)
|
||||
if setting.Git.Fsck.Enable {
|
||||
c.AddFunc("Repository health check", fmt.Sprintf("@every %dh", setting.Git.Fsck.Interval), models.GitFsck)
|
||||
}
|
||||
c.AddFunc("Check repository statistics", "@every 24h", models.CheckRepoStats)
|
||||
c.Start()
|
||||
}
|
||||
|
||||
func ListEntries() []*Entry {
|
||||
return c.Entries()
|
||||
}
|
@@ -126,11 +126,26 @@ var (
|
||||
Git struct {
|
||||
MaxGitDiffLines int
|
||||
GcArgs []string `delim:" "`
|
||||
Fsck struct {
|
||||
Enable bool
|
||||
Interval int
|
||||
Args []string `delim:" "`
|
||||
} `ini:"git.fsck"`
|
||||
}
|
||||
|
||||
// Cron tasks.
|
||||
Cron struct {
|
||||
UpdateMirror struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
} `ini:"cron.update_mirrors"`
|
||||
RepoHealthCheck struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
Args []string `delim:" "`
|
||||
} `ini:"cron.repo_health_check"`
|
||||
CheckRepoStats struct {
|
||||
Enabled bool
|
||||
RunAtStart bool
|
||||
Schedule string
|
||||
} `ini:"cron.check_repo_stats"`
|
||||
}
|
||||
|
||||
// I18n settings.
|
||||
@@ -361,6 +376,8 @@ func NewConfigContext() {
|
||||
|
||||
if err = Cfg.Section("git").MapTo(&Git); err != nil {
|
||||
log.Fatal(4, "Fail to map Git settings: %v", err)
|
||||
} else if Cfg.Section("cron").MapTo(&Cron); err != nil {
|
||||
log.Fatal(4, "Fail to map Cron settings: %v", err)
|
||||
}
|
||||
|
||||
Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
|
||||
|
Reference in New Issue
Block a user