fix report interval

This commit is contained in:
yuzuki999 2023-05-19 11:34:34 +08:00
parent 3f6f80b5e5
commit 13607c104d

View File

@ -15,24 +15,24 @@ import (
func (c *Controller) initTask() { func (c *Controller) initTask() {
// fetch node info task // fetch node info task
c.nodeInfoMonitorPeriodic = &task.Periodic{ c.nodeInfoMonitorPeriodic = &task.Periodic{
Interval: time.Duration(c.nodeInfo.BaseConfig.PullInterval.(int)) * time.Second, Interval: c.nodeInfo.BaseConfig.PullInterval.(time.Duration),
Execute: c.nodeInfoMonitor, Execute: c.nodeInfoMonitor,
} }
// fetch user list task // fetch user list task
c.userReportPeriodic = &task.Periodic{ c.userReportPeriodic = &task.Periodic{
Interval: time.Duration(c.nodeInfo.BaseConfig.PushInterval.(int)) * time.Second, Interval: c.nodeInfo.BaseConfig.PushInterval.(time.Duration),
Execute: c.reportUserTraffic, Execute: c.reportUserTraffic,
} }
log.Printf("[%s: %d] Start monitor node status", c.nodeInfo.NodeType, c.nodeInfo.NodeId) log.Printf("[%s: %d] Start monitor node status", c.nodeInfo.NodeType, c.nodeInfo.NodeId)
// delay to start nodeInfoMonitor // delay to start nodeInfoMonitor
go func() { go func() {
time.Sleep(time.Duration(c.nodeInfo.BaseConfig.PullInterval.(int)) * time.Second) time.Sleep(c.nodeInfo.BaseConfig.PullInterval.(time.Duration))
_ = c.nodeInfoMonitorPeriodic.Start() _ = c.nodeInfoMonitorPeriodic.Start()
}() }()
log.Printf("[%s: %d] Start report node status", c.nodeInfo.NodeType, c.nodeInfo.NodeId) log.Printf("[%s: %d] Start report node status", c.nodeInfo.NodeType, c.nodeInfo.NodeId)
// delay to start userReport // delay to start userReport
go func() { go func() {
time.Sleep(time.Duration(c.nodeInfo.BaseConfig.PushInterval.(int)) * time.Second) time.Sleep(c.nodeInfo.BaseConfig.PushInterval.(time.Duration))
_ = c.userReportPeriodic.Start() _ = c.userReportPeriodic.Start()
}() }()
if c.nodeInfo.Tls != 0 && c.CertConfig.CertMode != "none" && if c.nodeInfo.Tls != 0 && c.CertConfig.CertMode != "none" &&