package main import ( "ruleModelEngine/config" //"annotation_service/db" "basic.com/valib/logger.git" "flag" "ruleModelEngine/rule" "time" ) var env = flag.String("app", "app", "read database info") func init() { config.Init(*env) var logFile = config.LogConf.Path + "annotation_service.log" logger.InitLogger(logFile, config.LogConf.Level, config.LogConf.MaxSize, config.LogConf.MaxBackups, config.LogConf.MaxAge) logger.Info("loginit success !") } func main() { //db.UpdatePersonStatusByIds() immediate := flag.Bool("immediate", true, "whether to execute immediately") flag.Parse() if *immediate { logger.Info("Executing immediately...") rule.ExecuteTask() } now := time.Now() next := time.Date(now.Year(), now.Month(), now.Day()+1, 1, 0, 0, 0, now.Location()) duration := next.Sub(now) timer := time.NewTimer(duration) logger.Info("The program has started and will execute at one o'clock in the early morning every night.") for { <-timer.C logger.Info("Executing at 1 AM...") rule.ExecuteTask() next = next.Add(24 * time.Hour) timer.Reset(next.Sub(time.Now())) } }