func init() { if size, _ := beego.AppConfig.Int("jobs.pool"); size > 0 { workPool = make(chan bool, size) } mainCron = cron.New() mainCron.Start() }
func InitCorn() { conf, err := revel.LoadConfig("app.conf") if err != nil { revel.ERROR.Panicln("读取app.conf失败") } cronPoolSize, _ := conf.Raw().Int(revel.RunMode, "cron.poolSize") workPool = make(chan bool, cronPoolSize) mainCron = cron.New() // job := NewCommandJob("11111", "zhangsan", "ls") // mainCron.Schedule(Every(5*time.Second+5*time.Nanosecond), job) // AddJob("1 1 10 14,18 9 ?", job) mainCron.Start() revel.INFO.Printf(mate, cronPoolSize) }