You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
654 B

3 years ago
  1. package initialize
  2. import (
  3. "fmt"
  4. "github.com/flipped-aurora/gin-vue-admin/server/config"
  5. "github.com/flipped-aurora/gin-vue-admin/server/global"
  6. "github.com/flipped-aurora/gin-vue-admin/server/utils"
  7. )
  8. func Timer() {
  9. if global.GVA_CONFIG.Timer.Start {
  10. for i := range global.GVA_CONFIG.Timer.Detail {
  11. go func(detail config.Detail) {
  12. global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() {
  13. err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval)
  14. if err != nil {
  15. fmt.Println("timer error:", err)
  16. }
  17. })
  18. }(global.GVA_CONFIG.Timer.Detail[i])
  19. }
  20. }
  21. }