Ver Fonte

wip:cron修改

wangkaiyue há 2 anos atrás
pai
commit
42f700f74f
3 ficheiros alterados com 8 adições e 4 exclusões
  1. 2 2
      config.json
  2. 3 1
      entity/mananger/aheadManager.go
  3. 3 1
      entity/mananger/customManager.go

+ 2 - 2
config.json

@@ -2,14 +2,14 @@
   "webPort": "825",
   "ahead": {
     "prop": 0.1,
-    "updateCron": "",
+    "updateCron": "0 30 0 ? * 0",
     "saveClickTimes": 2,
     "dailyTimes": 1000
   },
   "custom": {
     "prop": 1,
     "searchPool": 1,
-    "updateCron": ""
+    "updateCron": "0 0 0 ? * 0"
   },
   "testUid": [
     "61f3a3c746af8f8a5c513175",

+ 3 - 1
entity/mananger/aheadManager.go

@@ -82,10 +82,12 @@ func (this *AheadManager) checkGroupUser(userId string) (exists bool) {
 //ScheduledTasks 定时任务
 func (this *AheadManager) ScheduledTasks() {
 	if this.Conf.UpdateCron != "" {
+		c := cron.New(cron.WithSeconds())
 		// 给对象增加定时任务
-		if _, err := cron.New().AddFunc(this.Conf.UpdateCron, this.UpdateUserGroupJob); err != nil {
+		if _, err := c.AddFunc(this.Conf.UpdateCron, this.UpdateUserGroupJob); err != nil {
 			panic(err)
 		}
+		c.Run()
 	}
 	//首次运行圈选用户
 	go this.UpdateUserGroupJob()

+ 3 - 1
entity/mananger/customManager.go

@@ -84,10 +84,12 @@ func (this *CustomManager) GetData(userId, keyWords string, isNew bool) map[stri
 // ScheduledTasks 定时任务
 func (this *CustomManager) ScheduledTasks() {
 	if this.Conf.UpdateCron != "" {
+		c := cron.New(cron.WithSeconds())
 		// 给对象增加定时任务
-		if _, err := cron.New().AddFunc(this.Conf.UpdateCron, this.UpdateUserGroupJob); err != nil {
+		if _, err := c.AddFunc(this.Conf.UpdateCron, this.UpdateUserGroupJob); err != nil {
 			panic(err)
 		}
+		c.Run()
 	}
 	//首次运行圈选用户
 	this.UpdateUserGroupJob()