From 5a96112d242c5e826ae5d8380861538df9e90ae8 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Fri, 2 Feb 2024 14:14:40 +0800 Subject: [PATCH] fix: fix the error --- tools/component/component.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index 3624c03c9..e86761ec9 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -61,9 +61,9 @@ func initCfg() error { } type checkFunc struct { - name string - function func() error - authInfo string + name string + function func() error + authErrInfo string } func main() { @@ -79,11 +79,11 @@ func main() { checks := []checkFunc{ //{name: "Mysql", function: checkMysql}, - {name: "Mongo", function: checkMongo, authInfo: MongoAuthFailed}, - {name: "Redis", function: checkRedis, authInfo: RedisAuthFailed}, - {name: "Minio", function: checkMinio, authInfo: MinioAuthFailed}, - {name: "Zookeeper", function: checkZookeeper, authInfo: ZkAuthFailed}, - {name: "Kafka", function: checkKafka, authInfo: KafkaAuthFailed}, + {name: "Mongo", function: checkMongo, authErrInfo: MongoAuthFailed}, + {name: "Redis", function: checkRedis, authErrInfo: RedisAuthFailed}, + {name: "Minio", function: checkMinio, authErrInfo: MinioAuthFailed}, + {name: "Zookeeper", function: checkZookeeper, authErrInfo: ZkAuthFailed}, + {name: "Kafka", function: checkKafka, authErrInfo: KafkaAuthFailed}, } for i := 0; i < maxRetry; i++ { @@ -101,25 +101,25 @@ func main() { for _, check := range checks { err = check.function() if err != nil { - if errorJudge(err, check.authInfo) { + if errorJudge(err, check.authErrInfo) { disruptions = true } - ErrorPrint(fmt.Sprintf("Starting %s failed, %v, the conneted info is:%s", check.name, err, errInfo)) + ErrorPrint(fmt.Sprintf("Starting %s failed:%v, conneted info:%s", check.name, err, errInfo)) allSuccess = false break } else { - component.SuccessPrint(fmt.Sprintf("%s connected successfully, the addr is:%s", check.name, errInfo)) + component.SuccessPrint(fmt.Sprintf("%s connected successfully, address:%s", check.name, errInfo)) } } - if allSuccess { - component.SuccessPrint("All components started successfully!") + if disruptions { + component.ErrorPrint(fmt.Sprintf("component check exit,err: %v", err)) return } - if disruptions { - component.ErrorPrint(fmt.Sprintf("component check exit,err: %v", err)) + if allSuccess { + component.SuccessPrint("All components started successfully!") return } }