task.go 670 B

123456789101112131415161718192021222324252627
  1. package services
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/beego/beego/v2/task"
  6. )
  7. func Task() {
  8. fmt.Println("task start")
  9. //SyncYesterdayLogs(nil)
  10. // 每日同步接口日志
  11. syncYesterdayLogs := task.NewTask("SyncYesterdayLogs", "0 0 4 * * * ", SyncYesterdayLogs)
  12. task.AddTask("每日同步接口日志", syncYesterdayLogs)
  13. // 每日同步查研观向接口日志
  14. syncYesterdayLogsByCygx := task.NewTask("SyncYesterdayLogsByCygx", "0 30 4 * * * ", SyncYesterdayLogsByCygx)
  15. task.AddTask("每日同步查研观向接口日志", syncYesterdayLogsByCygx)
  16. task.StartTask()
  17. cxt := new(context.Context)
  18. SyncYesterdayLogsByCygx(*cxt)
  19. fmt.Println("task end")
  20. }