Skip to content

Commit

Permalink
docker_script
Browse files Browse the repository at this point in the history
Signed-off-by: hanzhixiao <[email protected]>
  • Loading branch information
hanzhixiao committed Aug 18, 2023
1 parent 8e2ad0a commit c3f0446
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tools/component/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func initCfg() error {
if err = yaml.Unmarshal(data, &config.Config); err != nil {
return err
}
fmt.Println(config.Config.Mysql.Address)
return nil
}

Expand Down Expand Up @@ -143,12 +142,12 @@ func checkMysql() error {
config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql")
db, err := gorm.Open(mysql.Open(dsn), nil)
if err != nil {
return err
return errs.Wrap(err)
} else {
sqlDB, err = db.DB()
err = sqlDB.Ping()
if err != nil {
return err
return errs.Wrap(err)
}
}
return nil
Expand All @@ -173,11 +172,11 @@ func checkMongo() error {
fmt.Sprintf("mongodb://%v:%v@%v/?authSource=admin",
config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts)))
if err != nil {
return err
return errs.Wrap(err)
} else {
err = client.Ping(context.TODO(), &readpref.ReadPref{})
if err != nil {
return err
return errs.Wrap(err)
}
}
return nil
Expand All @@ -192,7 +191,7 @@ func checkMinio() error {
Secure: u.Scheme == "https",
})
if err != nil {
return err
return errs.Wrap(err)
}

cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration) * time.Second)
Expand All @@ -202,7 +201,7 @@ func checkMinio() error {
}
}()
if err != nil {
return err
return errs.Wrap(err)
} else {
if minioClient.IsOffline() {
return ErrComponentStart.Wrap("Minio server is offline")
Expand Down Expand Up @@ -237,7 +236,7 @@ func checkRedis() error {
}
_, err := redisClient.Ping(context.Background()).Result()
if err != nil {
return err
return errs.Wrap(err)
}
return nil
}
Expand All @@ -251,16 +250,16 @@ func checkZookeeper() error {
}()
c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second)
if err != nil {
return err
return errs.Wrap(err)
} else {
if config.Config.Zookeeper.Username != "" && config.Config.Zookeeper.Password != "" {
if err := c.AddAuth("digest", []byte(config.Config.Zookeeper.Username+":"+config.Config.Zookeeper.Password)); err != nil {
return err
return errs.Wrap(err)
}
}
_, _, err = c.Get("/")
if err != nil {
return err
return errs.Wrap(err)
}
}
return nil
Expand All @@ -281,7 +280,7 @@ func checkKafka() error {
}
kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, cfg)
if err != nil {
return err
return errs.Wrap(err)
} else {
topics, err := kafkaClient.Topics()
if err != nil {
Expand Down

0 comments on commit c3f0446

Please sign in to comment.