fix: fix the error

pull/1868/head
luhaoling 2 years ago
parent e729fe62e1
commit 5a96112d24

@ -61,9 +61,9 @@ func initCfg() error {
} }
type checkFunc struct { type checkFunc struct {
name string name string
function func() error function func() error
authInfo string authErrInfo string
} }
func main() { func main() {
@ -79,11 +79,11 @@ func main() {
checks := []checkFunc{ checks := []checkFunc{
//{name: "Mysql", function: checkMysql}, //{name: "Mysql", function: checkMysql},
{name: "Mongo", function: checkMongo, authInfo: MongoAuthFailed}, {name: "Mongo", function: checkMongo, authErrInfo: MongoAuthFailed},
{name: "Redis", function: checkRedis, authInfo: RedisAuthFailed}, {name: "Redis", function: checkRedis, authErrInfo: RedisAuthFailed},
{name: "Minio", function: checkMinio, authInfo: MinioAuthFailed}, {name: "Minio", function: checkMinio, authErrInfo: MinioAuthFailed},
{name: "Zookeeper", function: checkZookeeper, authInfo: ZkAuthFailed}, {name: "Zookeeper", function: checkZookeeper, authErrInfo: ZkAuthFailed},
{name: "Kafka", function: checkKafka, authInfo: KafkaAuthFailed}, {name: "Kafka", function: checkKafka, authErrInfo: KafkaAuthFailed},
} }
for i := 0; i < maxRetry; i++ { for i := 0; i < maxRetry; i++ {
@ -101,25 +101,25 @@ func main() {
for _, check := range checks { for _, check := range checks {
err = check.function() err = check.function()
if err != nil { if err != nil {
if errorJudge(err, check.authInfo) { if errorJudge(err, check.authErrInfo) {
disruptions = true 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 allSuccess = false
break break
} else { } 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 { if disruptions {
component.SuccessPrint("All components started successfully!") component.ErrorPrint(fmt.Sprintf("component check exit,err: %v", err))
return return
} }
if disruptions { if allSuccess {
component.ErrorPrint(fmt.Sprintf("component check exit,err: %v", err)) component.SuccessPrint("All components started successfully!")
return return
} }
} }

Loading…
Cancel
Save