main.go 805 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "context"
  4. //"context"
  5. //_ "getuser/internal/packed"
  6. //"github.com/gogf/gf/v2/frame/g"
  7. //"github.com/gogf/gf/v2/os/gcron"
  8. _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
  9. _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
  10. "github.com/gogf/gf/v2/frame/g"
  11. "github.com/gogf/gf/v2/os/gcron"
  12. "github.com/gogf/gf/v2/os/gctx"
  13. "newuserGet/internal/logic"
  14. )
  15. func main() {
  16. var (
  17. err error
  18. ctx = gctx.New()
  19. )
  20. //logic.Task(ctx)
  21. //
  22. taskRun := g.Cfg().MustGet(ctx, "task.taskRun").Bool()
  23. if taskRun {
  24. cronStr := g.Cfg().MustGet(ctx, "task.cron").String()
  25. _, err = gcron.AddSingleton(ctx, cronStr, func(ctx context.Context) {
  26. g.Log().Print(ctx, "doing start")
  27. logic.Task(ctx)
  28. g.Log().Print(ctx, "end")
  29. })
  30. if err != nil {
  31. panic(err)
  32. }
  33. }
  34. select {}
  35. }