diff --git a/modules/cron/tasks_basic.go b/modules/cron/tasks_basic.go index 438c4a500..f42710618 100644 --- a/modules/cron/tasks_basic.go +++ b/modules/cron/tasks_basic.go @@ -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() } diff --git a/routers/init.go b/routers/init.go index ae700e82b..dafe0a202 100755 --- a/routers/init.go +++ b/routers/init.go @@ -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()