2022-08-08 11:30:10 +08:00
|
|
|
package timedTask
|
2021-06-28 15:42:25 +08:00
|
|
|
|
|
|
|
|
import (
|
2022-08-08 11:30:10 +08:00
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
|
"Open_IM/pkg/utils"
|
|
|
|
|
"github.com/robfig/cron/v3"
|
2021-06-28 15:42:25 +08:00
|
|
|
)
|
|
|
|
|
|
2022-08-08 11:30:10 +08:00
|
|
|
func main() {
|
|
|
|
|
log.NewInfo(utils.OperationIDGenerator(), "start cron task")
|
|
|
|
|
c := cron.New()
|
|
|
|
|
_, err := c.AddFunc("30 3-6,20-23 * * *", func() {
|
|
|
|
|
operationID := utils.OperationIDGenerator()
|
|
|
|
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, "", constant.ReadDiffusion); err != nil {
|
|
|
|
|
log.NewError(operationID)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
2021-06-28 15:42:25 +08:00
|
|
|
}
|
2022-08-08 11:30:10 +08:00
|
|
|
c.Start()
|
2021-06-28 15:42:25 +08:00
|
|
|
}
|