diff options
author | zeripath <art27@cantab.net> | 2020-05-17 00:31:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 19:31:38 -0400 |
commit | 9a2e47b23a6d460acfce9b1b77e6f9fb06ca1b75 (patch) | |
tree | b1852472e1ecf6bdb1822b41655bdaf8afd87c1b /modules/setting/cron.go | |
parent | c18144086f9d4a06adbd4a7c08cfa6dab91224ec (diff) | |
download | gitea-9a2e47b23a6d460acfce9b1b77e6f9fb06ca1b75.tar.gz gitea-9a2e47b23a6d460acfce9b1b77e6f9fb06ca1b75.zip |
Refactor Cron and merge dashboard tasks (#10745)
* Refactor Cron and merge dashboard tasks
* Merge Cron and Dashboard tasks
* Make every cron task report a system notice on completion
* Refactor the creation of these tasks
* Ensure that execution counts of tasks is correct
* Allow cron tasks to be started from the cron page
* golangci-lint fixes
* Enforce that only one task with the same name can be registered
Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix name check
Signed-off-by: Andrew Thornton <art27@cantab.net>
* as per @guillep2k
* as per @lafriks
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add git.CommandContext variants
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/setting/cron.go')
-rw-r--r-- | modules/setting/cron.go | 129 |
1 files changed, 4 insertions, 125 deletions
diff --git a/modules/setting/cron.go b/modules/setting/cron.go index 77f55168aa..c8228ddaa8 100644 --- a/modules/setting/cron.go +++ b/modules/setting/cron.go @@ -4,129 +4,8 @@ package setting -import ( - "time" - - "code.gitea.io/gitea/modules/log" -) - -var ( - - // Cron tasks - Cron = struct { - UpdateMirror struct { - Enabled bool - RunAtStart bool - Schedule string - } `ini:"cron.update_mirrors"` - RepoHealthCheck struct { - Enabled bool - RunAtStart bool - Schedule string - Timeout time.Duration - Args []string `delim:" "` - } `ini:"cron.repo_health_check"` - CheckRepoStats struct { - Enabled bool - RunAtStart bool - Schedule string - } `ini:"cron.check_repo_stats"` - ArchiveCleanup struct { - Enabled bool - RunAtStart bool - Schedule string - OlderThan time.Duration - } `ini:"cron.archive_cleanup"` - SyncExternalUsers struct { - Enabled bool - RunAtStart bool - Schedule string - UpdateExisting bool - } `ini:"cron.sync_external_users"` - DeletedBranchesCleanup struct { - Enabled bool - RunAtStart bool - Schedule string - OlderThan time.Duration - } `ini:"cron.deleted_branches_cleanup"` - UpdateMigrationPosterID struct { - Schedule string - } `ini:"cron.update_migration_poster_id"` - }{ - UpdateMirror: struct { - Enabled bool - RunAtStart bool - Schedule string - }{ - Enabled: true, - RunAtStart: false, - Schedule: "@every 10m", - }, - RepoHealthCheck: struct { - Enabled bool - RunAtStart bool - Schedule string - Timeout time.Duration - Args []string `delim:" "` - }{ - Enabled: true, - RunAtStart: false, - Schedule: "@every 24h", - Timeout: 60 * time.Second, - Args: []string{}, - }, - CheckRepoStats: struct { - Enabled bool - RunAtStart bool - Schedule string - }{ - Enabled: true, - RunAtStart: true, - Schedule: "@every 24h", - }, - ArchiveCleanup: struct { - Enabled bool - RunAtStart bool - Schedule string - OlderThan time.Duration - }{ - Enabled: true, - RunAtStart: true, - Schedule: "@every 24h", - OlderThan: 24 * time.Hour, - }, - SyncExternalUsers: struct { - Enabled bool - RunAtStart bool - Schedule string - UpdateExisting bool - }{ - Enabled: true, - RunAtStart: false, - Schedule: "@every 24h", - UpdateExisting: true, - }, - DeletedBranchesCleanup: struct { - Enabled bool - RunAtStart bool - Schedule string - OlderThan time.Duration - }{ - Enabled: true, - RunAtStart: true, - Schedule: "@every 24h", - OlderThan: 24 * time.Hour, - }, - UpdateMigrationPosterID: struct { - Schedule string - }{ - Schedule: "@every 24h", - }, - } -) - -func newCron() { - if err := Cfg.Section("cron").MapTo(&Cron); err != nil { - log.Fatal("Failed to map Cron settings: %v", err) - } +// GetCronSettings maps the cron subsection to the provided config +func GetCronSettings(name string, config interface{}) (interface{}, error) { + err := Cfg.Section("cron." + name).MapTo(config) + return config, err } |