|
@@ -14,12 +14,27 @@ import (
|
|
|
|
|
|
func AddTasksToScheduler() {
|
|
|
for _, t := range base.GetTasks() {
|
|
|
- if t.RunMode == web.BConfig.RunMode {
|
|
|
+ //if t.RunMode == web.BConfig.RunMode {
|
|
|
+ if needAddTask(t.RunMode, web.BConfig.RunMode) {
|
|
|
tk := task.NewTask(string(t.Name), t.Cron, t.Run)
|
|
|
task.AddTask(string(t.Name), tk)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+func needAddTask(taskRunMode string, runMode string) bool {
|
|
|
+ switch taskRunMode {
|
|
|
+ case base.PROD:
|
|
|
+ return runMode == base.PROD
|
|
|
+ case base.TEST:
|
|
|
+ return runMode != base.PROD
|
|
|
+ case base.DEV:
|
|
|
+ return runMode == base.DEV
|
|
|
+ case base.FORBIDDEN:
|
|
|
+ return false
|
|
|
+ default:
|
|
|
+ return false
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// StartScheduler 启动任务调度器
|
|
|
func StartScheduler() {
|