wireguard-dashboard/cron/cron.go
coward 8884d945aa
All checks were successful
continuous-integration/drone/tag Build is passing
🆕新增离线客户端监听并且发送通知
2024-12-05 09:54:55 +08:00

21 lines
463 B
Go

package cron
import (
"gitee.ltd/lxh/logger/log"
"github.com/go-co-op/gocron/v2"
"time"
"wireguard-ui/cron/task"
)
func Task() {
sch, err := gocron.NewScheduler(gocron.WithLocation(time.Local))
if err != nil {
log.Errorf("初始化定时任务失败")
return
}
_, _ = sch.NewJob(gocron.DurationJob(3*time.Minute), gocron.NewTask(task.NetworkClient().ClientOfflineNotify())) // 每三分钟检测离线的客户端并且发送消息
sch.Start()
}