1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package init_serve
- import (
- "github.com/robfig/cron/v3"
- "hongze/hrms_api/global"
- "hongze/hrms_api/services/alarm_msg"
- rcrtService "hongze/hrms_api/services/rcrt"
- "hongze/hrms_api/utils"
- "time"
- )
- func InitTask() {
- if global.CONFIG.Serve.RunMode != "debug" {
- if utils.GetInterfaceAddrs() != "172.19.173.232" {
- return
- }
- }else{
- //return
- }
- c := cron.New(cron.WithSeconds())
- _, err := c.AddFunc("0 */5 * * * *", DownloadCvTask)
- if err != nil {
- global.LOG.Info("DownloadCvTask err"+err.Error())
- panic("DownloadCvTask err"+err.Error())
- }
- c.Start()
- }
- func DownloadCvTask() {
- global.LOG.Info("DownloadCvTask start")
- var err error
- var errMsg string
- defer func() {
- if err != nil{
- global.LOG.Info(utils.APPNAME+" 定时任务 出错"+time.Now().Format(utils.FormatDateTime)+";Err:"+errMsg+" "+err.Error())
- go alarm_msg.SendAlarmMsg(utils.APPNAME+" 定时任务 出错"+time.Now().Format(utils.FormatDateTime)+";Err:"+errMsg+" "+err.Error(), 3)
- }
- }()
- err, errMsg = rcrtService.DownloadCv()
- global.LOG.Info("DownloadCvTask end")
- return
- }
|