Browse Source

Conbine cron job

tags/v1.21.12.1
rogerluo410 4 years ago
parent
commit
97fbb8f87b
2 changed files with 62 additions and 12 deletions
  1. +62
    -0
      modules/cron/tasks_basic.go
  2. +0
    -12
      routers/init.go

+ 62
- 0
modules/cron/tasks_basic.go View File

@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/migrations"
repository_service "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/routers/repo"
mirror_service "code.gitea.io/gitea/services/mirror"
)

@@ -107,6 +108,61 @@ func registerUpdateMigrationPosterID() {
})
}

func registerHandleUnDecompressAttachment() {
RegisterTaskFatal("handle_undecompress_attachment", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@every 10m",
}, func(ctx context.Context, _ *models.User, _ Config) error {
repo.HandleUnDecompressAttachment()
return nil
})
}

func registerHandleBlockChainUnSuccessUsers() {
RegisterTaskFatal("handle_blockchain_unsuccess_users", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@every 10m",
}, func(ctx context.Context, _ *models.User, _ Config) error {
repo.HandleBlockChainUnSuccessUsers()
return nil
})
}

func registerHandleBlockChainUnSuccessRepos() {
RegisterTaskFatal("handle_blockchain_unsuccess_repos", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@every 1m",
}, func(ctx context.Context, _ *models.User, _ Config) error {
repo.HandleBlockChainUnSuccessRepos()
return nil
})
}

func registerHandleBlockChainMergedPulls() {
RegisterTaskFatal("handle_blockchain_merged_pull", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@every 1m",
}, func(ctx context.Context, _ *models.User, _ Config) error {
repo.HandleBlockChainMergedPulls()
return nil
})
}

func registerHandleBlockChainUnSuccessCommits() {
RegisterTaskFatal("handle_blockchain_unsuccess_commits", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@every 3m",
}, func(ctx context.Context, _ *models.User, _ Config) error {
repo.HandleBlockChainUnSuccessCommits()
return nil
})
}

func initBasicTasks() {
registerUpdateMirrorTask()
registerRepoHealthCheck()
@@ -115,4 +171,10 @@ func initBasicTasks() {
registerSyncExternalUsers()
registerDeletedBranchesCleanup()
registerUpdateMigrationPosterID()

registerHandleUnDecompressAttachment()
registerHandleBlockChainUnSuccessUsers()
registerHandleBlockChainUnSuccessRepos()
registerHandleBlockChainMergedPulls()
registerHandleBlockChainUnSuccessCommits()
}

+ 0
- 12
routers/init.go View File

@@ -31,7 +31,6 @@ import (
"code.gitea.io/gitea/modules/ssh"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/task"
"code.gitea.io/gitea/modules/timer"
"code.gitea.io/gitea/modules/webhook"
"code.gitea.io/gitea/services/mailer"
mirror_service "code.gitea.io/gitea/services/mirror"
@@ -135,17 +134,6 @@ func GlobalInit(ctx context.Context) {

NewServices()

// Launch cron job after DB configured.
if models.HasEngine {
log.Info("%s", unknwoni18n.Tr("en-US", "admin.dashboard.start_cron_job"))
go timer.LaunchCronJob()
} else {
if err := models.SetEngine(); err == nil {
log.Info("%s", unknwoni18n.Tr("en-US", "admin.dashboard.start_cron_job"))
go timer.LaunchCronJob()
}
}

if setting.InstallLock {
highlight.NewContext()
external.RegisterParsers()


Loading…
Cancel
Save