| @@ -21,7 +21,6 @@ import ( | |||||
| _ "code.gitea.io/gitea/modules/markup/csv" | _ "code.gitea.io/gitea/modules/markup/csv" | ||||
| _ "code.gitea.io/gitea/modules/markup/markdown" | _ "code.gitea.io/gitea/modules/markup/markdown" | ||||
| _ "code.gitea.io/gitea/modules/markup/orgmode" | _ "code.gitea.io/gitea/modules/markup/orgmode" | ||||
| _ "code.gitea.io/gitea/modules/timer" | |||||
| "github.com/urfave/cli" | "github.com/urfave/cli" | ||||
| ) | ) | ||||
| @@ -151,6 +151,9 @@ func getEngine() (*xorm.Engine, error) { | |||||
| engine.Dialect().SetParams(map[string]string{"rowFormat": "DYNAMIC"}) | engine.Dialect().SetParams(map[string]string{"rowFormat": "DYNAMIC"}) | ||||
| } | } | ||||
| engine.SetSchema(setting.Database.Schema) | engine.SetSchema(setting.Database.Schema) | ||||
| HasEngine = true | |||||
| return engine, nil | return engine, nil | ||||
| } | } | ||||
| @@ -3,10 +3,13 @@ package timer | |||||
| import ( | import ( | ||||
| "github.com/robfig/cron/v3" | "github.com/robfig/cron/v3" | ||||
| "code.gitea.io/gitea/modules/log" | |||||
| "code.gitea.io/gitea/routers/repo" | "code.gitea.io/gitea/routers/repo" | ||||
| ) | ) | ||||
| func init() { | |||||
| func LaunchCronJob() { | |||||
| log.Trace("Run cron job") | |||||
| c := cron.New() | c := cron.New() | ||||
| spec := "*/10 * * * *" | spec := "*/10 * * * *" | ||||
| @@ -1956,6 +1956,8 @@ dashboard.cron.finished=Cron: %[1]s has finished | |||||
| dashboard.delete_inactive_accounts = Delete all unactivated accounts | dashboard.delete_inactive_accounts = Delete all unactivated accounts | ||||
| dashboard.delete_inactive_accounts.started = Delete all unactivated accounts task started. | dashboard.delete_inactive_accounts.started = Delete all unactivated accounts task started. | ||||
| dashboard.delete_repo_archives = Delete all repository archives | dashboard.delete_repo_archives = Delete all repository archives | ||||
| dashboard.start_cron_job = Start to run cron jobs | |||||
| dashboard.start_cron_job_failed = Start to run cron jobs failed | |||||
| dashboard.delete_repo_archives.started = Delete all repository archives task started. | dashboard.delete_repo_archives.started = Delete all repository archives task started. | ||||
| dashboard.delete_missing_repos = Delete all repositories missing their Git files | dashboard.delete_missing_repos = Delete all repositories missing their Git files | ||||
| dashboard.delete_missing_repos.started = Delete all repositories missing their Git files task started. | dashboard.delete_missing_repos.started = Delete all repositories missing their Git files task started. | ||||
| @@ -31,6 +31,7 @@ import ( | |||||
| "code.gitea.io/gitea/modules/ssh" | "code.gitea.io/gitea/modules/ssh" | ||||
| "code.gitea.io/gitea/modules/storage" | "code.gitea.io/gitea/modules/storage" | ||||
| "code.gitea.io/gitea/modules/task" | "code.gitea.io/gitea/modules/task" | ||||
| "code.gitea.io/gitea/modules/timer" | |||||
| "code.gitea.io/gitea/modules/webhook" | "code.gitea.io/gitea/modules/webhook" | ||||
| "code.gitea.io/gitea/services/mailer" | "code.gitea.io/gitea/services/mailer" | ||||
| mirror_service "code.gitea.io/gitea/services/mirror" | mirror_service "code.gitea.io/gitea/services/mirror" | ||||
| @@ -134,6 +135,17 @@ func GlobalInit(ctx context.Context) { | |||||
| NewServices() | 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 { | if setting.InstallLock { | ||||
| highlight.NewContext() | highlight.NewContext() | ||||
| external.RegisterParsers() | external.RegisterParsers() | ||||