Commit 25de94e2 by Seefs Committed by GitHub

fix: test channel frequency (#2119)

parent 7b838d64
...@@ -625,7 +625,7 @@ func AutomaticallyTestChannels() { ...@@ -625,7 +625,7 @@ func AutomaticallyTestChannels() {
} }
for { for {
frequency := operation_setting.GetMonitorSetting().AutoTestChannelMinutes frequency := operation_setting.GetMonitorSetting().AutoTestChannelMinutes
time.Sleep(time.Duration(frequency) * time.Minute) time.Sleep(time.Duration(int(math.Round(frequency))) * time.Minute)
common.SysLog(fmt.Sprintf("automatically test channels with interval %d minutes", frequency)) common.SysLog(fmt.Sprintf("automatically test channels with interval %d minutes", frequency))
common.SysLog("automatically testing all channels") common.SysLog("automatically testing all channels")
_ = testAllChannels(false) _ = testAllChannels(false)
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
) )
type MonitorSetting struct { type MonitorSetting struct {
AutoTestChannelEnabled bool `json:"auto_test_channel_enabled"` AutoTestChannelEnabled bool `json:"auto_test_channel_enabled"`
AutoTestChannelMinutes int `json:"auto_test_channel_minutes"` AutoTestChannelMinutes float64 `json:"auto_test_channel_minutes"`
} }
// 默认配置 // 默认配置
...@@ -28,7 +28,7 @@ func GetMonitorSetting() *MonitorSetting { ...@@ -28,7 +28,7 @@ func GetMonitorSetting() *MonitorSetting {
frequency, err := strconv.Atoi(os.Getenv("CHANNEL_TEST_FREQUENCY")) frequency, err := strconv.Atoi(os.Getenv("CHANNEL_TEST_FREQUENCY"))
if err == nil && frequency > 0 { if err == nil && frequency > 0 {
monitorSetting.AutoTestChannelEnabled = true monitorSetting.AutoTestChannelEnabled = true
monitorSetting.AutoTestChannelMinutes = frequency monitorSetting.AutoTestChannelMinutes = float64(frequency)
} }
} }
return &monitorSetting return &monitorSetting
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment