Download setting/operation_setting/monitor_setting.go from AZILS/new-api: direct link, hf CLI and curl.
- Browser
- Download file 846 Bytes
-
https://huggingface.co/spaces/AZILS/new-api/resolve/main/setting/operation_setting/monitor_setting.go
- Command line
-
hf download hf://spaces/AZILS/new-api/setting/operation_setting/monitor_setting.go
-
curl -L -o monitor_setting.go https://huggingface.co/spaces/AZILS/new-api/resolve/main/setting/operation_setting/monitor_setting.go
846 Bytes
| package operation_setting | |
| import ( | |
| "os" | |
| "strconv" | |
| "github.com/QuantumNous/new-api/setting/config" | |
| ) | |
| type MonitorSetting struct { | |
| AutoTestChannelEnabled bool `json:"auto_test_channel_enabled"` | |
| AutoTestChannelMinutes float64 `json:"auto_test_channel_minutes"` | |
| } | |
| // 默认配置 | |
| var monitorSetting = MonitorSetting{ | |
| AutoTestChannelEnabled: false, | |
| AutoTestChannelMinutes: 10, | |
| } | |
| func init() { | |
| // 注册到全局配置管理器 | |
| config.GlobalConfig.Register("monitor_setting", &monitorSetting) | |
| } | |
| func GetMonitorSetting() *MonitorSetting { | |
| if os.Getenv("CHANNEL_TEST_FREQUENCY") != "" { | |
| frequency, err := strconv.Atoi(os.Getenv("CHANNEL_TEST_FREQUENCY")) | |
| if err == nil && frequency > 0 { | |
| monitorSetting.AutoTestChannelEnabled = true | |
| monitorSetting.AutoTestChannelMinutes = float64(frequency) | |
| } | |
| } | |
| return &monitorSetting | |
| } | |