47 lines
791 B
Go
47 lines
791 B
Go
package cron
|
|
|
|
import (
|
|
rds "proxy/Nredis"
|
|
rest "proxy/Nrestful"
|
|
|
|
"github.com/robfig/cron"
|
|
l4g "proxy/logger"
|
|
)
|
|
|
|
|
|
func cronClrExpRes() {// 3.1(+[29]/30/31); 5.1/7.1/10.1/12.1(+31);
|
|
rds.ClrExpRes()
|
|
}
|
|
|
|
func cronNtfSms() {
|
|
rest.RdbScanAlertSmsRecord()
|
|
}
|
|
|
|
var c *cron.Cron = nil
|
|
func CronStart(clrExp, ntfSms string) {
|
|
c = cron.New()
|
|
|
|
// add a func to run in cron time
|
|
//err := c.AddFunc("0 59 * * * ?", cron_rentThisMonth)
|
|
var err error
|
|
if clrExp != "" {
|
|
err = c.AddFunc(clrExp, cronClrExpRes)
|
|
if err != nil {
|
|
l4g.AppLog.Error("Add cron clear expire rr and acct error: %v", err)
|
|
}
|
|
}
|
|
|
|
if ntfSms != "" {
|
|
err = c.AddFunc(ntfSms, cronNtfSms)
|
|
if err != nil {
|
|
l4g.AppLog.Error("Add cron send notify sms error: %v", err)
|
|
}
|
|
}
|
|
|
|
c.Start()
|
|
}
|
|
|
|
func CronStop() {
|
|
c.Stop()
|
|
}
|