22 lines
374 B
Go
22 lines
374 B
Go
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/robfig/cron/v3"
|
|
"knowledge/api/crontab"
|
|
)
|
|
|
|
func StartCron() {
|
|
c := cron.New(cron.WithSeconds())
|
|
|
|
_, err := c.AddFunc("0 * * * * *", crontab.HandleQuestionQaExpire)
|
|
if err != nil {
|
|
panic("定时器启动失败:" + err.Error())
|
|
}
|
|
|
|
// 启动定时任务调度器
|
|
c.Start()
|
|
|
|
fmt.Println("初始化定时器成功......")
|
|
}
|