fix: test channel frequency (#2119)

This commit is contained in:
Seefs
2025-10-29 00:23:24 +09:00
committed by GitHub
parent 2581bea93e
commit 158b46eb4b
2 changed files with 4 additions and 4 deletions

View File

@@ -625,7 +625,7 @@ func AutomaticallyTestChannels() {
}
for {
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("automatically testing all channels")
_ = testAllChannels(false)

View File

@@ -8,8 +8,8 @@ import (
)
type MonitorSetting struct {
AutoTestChannelEnabled bool `json:"auto_test_channel_enabled"`
AutoTestChannelMinutes int `json:"auto_test_channel_minutes"`
AutoTestChannelEnabled bool `json:"auto_test_channel_enabled"`
AutoTestChannelMinutes float64 `json:"auto_test_channel_minutes"`
}
// 默认配置
@@ -28,7 +28,7 @@ func GetMonitorSetting() *MonitorSetting {
frequency, err := strconv.Atoi(os.Getenv("CHANNEL_TEST_FREQUENCY"))
if err == nil && frequency > 0 {
monitorSetting.AutoTestChannelEnabled = true
monitorSetting.AutoTestChannelMinutes = frequency
monitorSetting.AutoTestChannelMinutes = float64(frequency)
}
}
return &monitorSetting