添加再TimeUp执行前的NextTime调用
This commit is contained in:
parent
c4c38478be
commit
7f42baaa23
|
@ -6,6 +6,8 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"474420502.top/eson/crontabex"
|
||||||
|
|
||||||
"474420502.top/eson/structure/circular_linked"
|
"474420502.top/eson/structure/circular_linked"
|
||||||
|
|
||||||
"474420502.top/eson/curl2info"
|
"474420502.top/eson/curl2info"
|
||||||
|
@ -17,7 +19,7 @@ type ITask interface {
|
||||||
Init()
|
Init()
|
||||||
|
|
||||||
SetCrontab(cron string)
|
SetCrontab(cron string)
|
||||||
SetLastStatus(status bool)
|
GetCrontab() *crontab.Crontab
|
||||||
|
|
||||||
SetName(name string)
|
SetName(name string)
|
||||||
GetName() string
|
GetName() string
|
||||||
|
@ -172,6 +174,7 @@ func ExecuteOnPlan(task ITask, result chan string) {
|
||||||
taskname := task.GetName()
|
taskname := task.GetName()
|
||||||
urlname := task.GetCurl().Name
|
urlname := task.GetCurl().Name
|
||||||
|
|
||||||
|
task.NextTime() // 必须调用NextTime 才能触发TimeUp
|
||||||
for {
|
for {
|
||||||
interval := time.Second * 2
|
interval := time.Second * 2
|
||||||
if task.TimeUp() {
|
if task.TimeUp() {
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
package imitater
|
|
|
@ -1 +0,0 @@
|
||||||
package imitater
|
|
32
task.go
32
task.go
|
@ -1,9 +1,14 @@
|
||||||
package imitater
|
package imitater
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"474420502.top/test/logdb"
|
||||||
|
|
||||||
"474420502.top/eson/structure/circular_linked"
|
"474420502.top/eson/structure/circular_linked"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
|
||||||
"474420502.top/eson/crontabex"
|
"474420502.top/eson/crontabex"
|
||||||
"474420502.top/eson/curl2info"
|
"474420502.top/eson/curl2info"
|
||||||
|
@ -73,9 +78,9 @@ func (task *Task) SetCrontab(cron string) {
|
||||||
task.crontab = crontab.NewCrontab(cron)
|
task.crontab = crontab.NewCrontab(cron)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLastStatus 设置上次执行的状态 成功true 失败false
|
// GetCrontab 设置上次执行的状态 成功true 失败false
|
||||||
func (task *Task) SetLastStatus(status bool) {
|
func (task *Task) GetCrontab() *crontab.Crontab {
|
||||||
task.crontab.SetStatus(status)
|
return task.crontab
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimeUp 判断是否到了下次执行的时间点
|
// TimeUp 判断是否到了下次执行的时间点
|
||||||
|
@ -125,3 +130,24 @@ func (task *Task) Session() *requests.Session {
|
||||||
|
|
||||||
return task.session
|
return task.session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ADDataSave 公众存储数据的接口
|
||||||
|
func ADDataSave(task ITask, db *logdb.LogDB, adDataList []string) {
|
||||||
|
if len(adDataList) != 0 {
|
||||||
|
adDataStore, err := json.Marshal(adDataList)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
// log.Println(string(adDataStore))
|
||||||
|
uid, err := uuid.NewV4()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println(uid.String())
|
||||||
|
|
||||||
|
adinfo := task.GetADInfo()
|
||||||
|
db.ADInsert(uid.String(), adinfo.Device, adinfo.Platform, adinfo.AreaCC, "",
|
||||||
|
string(adDataStore), adinfo.SpiderID, adinfo.Channel, adinfo.Media, adinfo.CatchAccountID, 0, adinfo.Priority, time.Now())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user