You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cron.go 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2019 The Gitea 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 setting
  5. import (
  6. "time"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. var (
  10. // Cron tasks
  11. Cron = struct {
  12. UpdateMirror struct {
  13. Enabled bool
  14. RunAtStart bool
  15. Schedule string
  16. } `ini:"cron.update_mirrors"`
  17. RepoHealthCheck struct {
  18. Enabled bool
  19. RunAtStart bool
  20. Schedule string
  21. Timeout time.Duration
  22. Args []string `delim:" "`
  23. } `ini:"cron.repo_health_check"`
  24. CheckRepoStats struct {
  25. Enabled bool
  26. RunAtStart bool
  27. Schedule string
  28. } `ini:"cron.check_repo_stats"`
  29. ArchiveCleanup struct {
  30. Enabled bool
  31. RunAtStart bool
  32. Schedule string
  33. OlderThan time.Duration
  34. } `ini:"cron.archive_cleanup"`
  35. SyncExternalUsers struct {
  36. Enabled bool
  37. RunAtStart bool
  38. Schedule string
  39. UpdateExisting bool
  40. } `ini:"cron.sync_external_users"`
  41. DeletedBranchesCleanup struct {
  42. Enabled bool
  43. RunAtStart bool
  44. Schedule string
  45. OlderThan time.Duration
  46. } `ini:"cron.deleted_branches_cleanup"`
  47. }{
  48. UpdateMirror: struct {
  49. Enabled bool
  50. RunAtStart bool
  51. Schedule string
  52. }{
  53. Enabled: true,
  54. RunAtStart: false,
  55. Schedule: "@every 10m",
  56. },
  57. RepoHealthCheck: struct {
  58. Enabled bool
  59. RunAtStart bool
  60. Schedule string
  61. Timeout time.Duration
  62. Args []string `delim:" "`
  63. }{
  64. Enabled: true,
  65. RunAtStart: false,
  66. Schedule: "@every 24h",
  67. Timeout: 60 * time.Second,
  68. Args: []string{},
  69. },
  70. CheckRepoStats: struct {
  71. Enabled bool
  72. RunAtStart bool
  73. Schedule string
  74. }{
  75. Enabled: true,
  76. RunAtStart: true,
  77. Schedule: "@every 24h",
  78. },
  79. ArchiveCleanup: struct {
  80. Enabled bool
  81. RunAtStart bool
  82. Schedule string
  83. OlderThan time.Duration
  84. }{
  85. Enabled: true,
  86. RunAtStart: true,
  87. Schedule: "@every 24h",
  88. OlderThan: 24 * time.Hour,
  89. },
  90. SyncExternalUsers: struct {
  91. Enabled bool
  92. RunAtStart bool
  93. Schedule string
  94. UpdateExisting bool
  95. }{
  96. Enabled: true,
  97. RunAtStart: false,
  98. Schedule: "@every 24h",
  99. UpdateExisting: true,
  100. },
  101. DeletedBranchesCleanup: struct {
  102. Enabled bool
  103. RunAtStart bool
  104. Schedule string
  105. OlderThan time.Duration
  106. }{
  107. Enabled: true,
  108. RunAtStart: true,
  109. Schedule: "@every 24h",
  110. OlderThan: 24 * time.Hour,
  111. },
  112. }
  113. )
  114. func newCron() {
  115. if err := Cfg.Section("cron").MapTo(&Cron); err != nil {
  116. log.Fatal("Failed to map Cron settings: %v", err)
  117. }
  118. }