Browse Source

🔧 refactor(channel): add validation for CHANNEL_TEST_FREQUENCY in automatic tests

CaIon 6 months ago
parent
commit
338e914a60
2 changed files with 6 additions and 2 deletions
  1. 4 0
      controller/channel-test.go
  2. 2 2
      main.go

+ 4 - 0
controller/channel-test.go

@@ -354,6 +354,10 @@ func TestAllChannels(c *gin.Context) {
 }
 
 func AutomaticallyTestChannels(frequency int) {
+	if frequency <= 0 {
+		common.SysLog("CHANNEL_TEST_FREQUENCY is not set or invalid, skipping automatic channel test")
+		return
+	}
 	for {
 		time.Sleep(time.Duration(frequency) * time.Minute)
 		common.SysLog("testing all channels")

+ 2 - 2
main.go

@@ -168,11 +168,11 @@ func InitResources() error {
 		common.SysLog("No .env file found, using default environment variables. If needed, please create a .env file and set the relevant variables.")
 	}
 
+	common.SetupLogger()
+
 	// 加载环境变量
 	common.InitEnv()
 
-	common.SetupLogger()
-
 	// Initialize model settings
 	ratio_setting.InitRatioSettings()