fix: del the disruptions code

pull/1868/head
luhaoling 2 years ago
parent 6e2b50d63b
commit e0fd4ee4c1

@ -15,7 +15,6 @@
package main
import (
"errors"
"flag"
"fmt"
"github.com/IBM/sarama"
@ -44,11 +43,6 @@ const (
var (
cfgPath = flag.String("c", defaultCfgPath, "Path to the configuration file")
MongoAuthFailed = "Authentication failed."
RedisAuthFailed = "NOAUTH Authentication required."
MinioAuthFailed = "Minio Authentication failed"
ZkAuthFailed = "zk Authentication failed"
KafkaAuthFailed = "SASL Authentication failed"
)
func initCfg() error {
@ -63,7 +57,6 @@ func initCfg() error {
type checkFunc struct {
name string
function func() error
authErrInfo string
}
func main() {
@ -79,11 +72,11 @@ func main() {
checks := []checkFunc{
//{name: "Mysql", function: checkMysql},
{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},
{name: "Mongo", function: checkMongo},
{name: "Redis", function: checkRedis},
{name: "Minio", function: checkMinio},
{name: "Zookeeper", function: checkZookeeper},
{name: "Kafka", function: checkKafka},
}
for i := 0; i < maxRetry; i++ {
@ -92,29 +85,16 @@ func main() {
}
fmt.Printf("Checking components Round %v...\n", i+1)
var (
err error
errInfo string
disruptions bool
)
var err error
allSuccess := true
for _, check := range checks {
err = check.function()
if err != nil {
if errorJudge(err, check.authErrInfo) {
disruptions = true
}
ErrorPrint(fmt.Sprintf("Starting %s failed:%v, conneted info:%s", check.name, err, errInfo))
ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
allSuccess = false
} else {
component.SuccessPrint(fmt.Sprintf("%s connected successfully, address:%s", check.name, errInfo))
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
}
}
if disruptions {
component.ErrorPrint(fmt.Sprintf("component check exit,err: %v", err))
return
}
if allSuccess {
@ -275,9 +255,3 @@ func colorPrint(colorCode int, format string, a ...interface{}) {
log.Printf("\x1b[%dm%s\x1b[0m\n", colorCode, fmt.Sprintf(format, a...))
}
func errorJudge(err error, errMsg string) bool {
if strings.Contains(errors.Unwrap(err).Error(), errMsg) {
return true
}
return false
}

Loading…
Cancel
Save