package bootstrap

import (
	"designs/crons"
	"designs/global"
	"fmt"
	"github.com/robfig/cron/v3"
	"time"
)

func InitializeCron() {
	global.App.Cron = cron.New(cron.WithSeconds())

	go func() {
		global.App.Cron.AddFunc("0 0 2 * * *", func() {
			fmt.Println(time.Now())
		})

		global.App.Cron.AddFunc("0 0 1 * * *", crons.ActiveDelete)         //清理用户在线数据文件夹
		global.App.Cron.AddFunc("0 0 2 * * *", crons.OnlineDatabaseDelete) //清理用户在线数据数据库
		global.App.Cron.AddFunc("0 0 1 * * *", crons.AdsDataSummary)       //汇总昨日的广告数据
		global.App.Cron.Start()
		defer global.App.Cron.Stop()
		select {}
	}()
}
