From 61f4aeb03adbf4cbe7418067c9b688d23729fe7b Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 11:59:57 +0800 Subject: [PATCH 01/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- go.mod | 2 +- go.work | 3 +- tools/component/check_component.go | 160 +++++++++++++++++++++++++++++ tools/component/go.mod | 3 + 4 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 tools/component/check_component.go create mode 100644 tools/component/go.mod diff --git a/go.mod b/go.mod index 4e875c741..1b9ea462b 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,7 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible github.com/go-redis/redis v6.15.9+incompatible github.com/go-sql-driver/mysql v1.7.1 + github.com/go-zookeeper/zk v1.0.3 github.com/redis/go-redis/v9 v9.0.5 github.com/tencentyun/cos-go-sdk-v5 v0.7.42 ) @@ -68,7 +69,6 @@ require ( github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-zookeeper/zk v1.0.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.5.9 // indirect diff --git a/go.work b/go.work index 09e86f032..757933536 100644 --- a/go.work +++ b/go.work @@ -1,7 +1,8 @@ go 1.20 use ( - . + . + ./tools/component ./tools/infra ./tools/ncpu ) diff --git a/tools/component/check_component.go b/tools/component/check_component.go new file mode 100644 index 000000000..93461f640 --- /dev/null +++ b/tools/component/check_component.go @@ -0,0 +1,160 @@ +package main + +import ( + "context" + "database/sql" + "fmt" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/tools/utils" + "github.com/Shopify/sarama" + "github.com/go-zookeeper/zk" + "github.com/minio/minio-go/v7" + "github.com/redis/go-redis/v9" + "go.mongodb.org/mongo-driver/mongo/readpref" + "net" + "net/url" + "strings" + "time" + + "github.com/minio/minio-go/v7/pkg/credentials" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +const ( + sqlDriver = "mysql" + minioHealthCheckDuration = 1 + maxRetry = 3 +) + +func main() { + + for i := 0; i < maxRetry; i++ { + success := 1 + // Check MySQL + db, err := sql.Open(sqlDriver, fmt.Sprintf("%s:%s@tcp(%s)/", + config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address)) + if err != nil { + fmt.Printf("Cannot connect to MySQL: %v", err) + success = 0 + } + err = db.Ping() + if err != nil { + fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) + success = 0 + } + db.Close() + + // Check MongoDB + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( + fmt.Sprintf("mongodb://%s:%s@%s", + config.Config.Mongo.Username, config.Config.Mongo.Password, config.Config.Mongo.Address))) + if err != nil { + fmt.Printf("Cannot connect to MongoDB: %v", err) + success = 0 + } + err = client.Ping(context.TODO(), &readpref.ReadPref{}) + if err != nil { + fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) + success = 0 + } + client.Disconnect(context.TODO()) + + // Check Minio + if config.Config.Object.Enable == "minio" { + if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" && config.Config.Object.ApiURL == config.Config.Object.Minio.Endpoint { + fmt.Printf("ApiURL contain the same address with Endpoint: %v. please modify the config file", config.Config.Object.ApiURL) + } + minioClient, err := minio.New(config.Config.Object.Minio.Endpoint, &minio.Options{ + Creds: credentials.NewStaticV4(config.Config.Object.Minio.AccessKeyID, config.Config.Object.Minio.SecretAccessKey, ""), + Secure: false, + }) + if err != nil { + fmt.Printf("Cannot connect to Minio: %v", err) + success = 0 + } + cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration)) + if err != nil { + fmt.Printf("starting minio health check failed:%v", err) + success = 0 + } + if minioClient.IsOffline() { + fmt.Printf("Error: minio server is offline.") + success = 0 + } + cancel() + } + + // Check Redis + var redisClient redis.UniversalClient + if len(config.Config.Redis.Address) > 1 { + redisClient = redis.NewClusterClient(&redis.ClusterOptions{ + Addrs: config.Config.Redis.Address, + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } else { + redisClient = redis.NewClient(&redis.Options{ + Addr: config.Config.Redis.Address[0], + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } + _, err = redisClient.Ping(context.Background()).Result() + if err != nil { + fmt.Printf("Cannot connect to Redis: %v", err) + success = 0 + } + + // Check Zookeeper + c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) + if err != nil { + fmt.Printf("Cannot connect to Zookeeper: %v", err) + success = 0 + } + c.Close() + + // Check Kafka + kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, &sarama.Config{}) + if err != nil { + fmt.Printf("Cannot connect to Kafka: %v", err) + success = 0 + } else { + topics, err := kafkaClient.Topics() + if err != nil { + fmt.Println("get kafka topic error") + success = 0 + } + if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { + fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic) + success = 0 + } + if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { + fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic) + success = 0 + } + if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { + fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic) + success = 0 + } + } + kafkaClient.Close() + if success == 1 { + fmt.Println("all compose check pass") + return + } + time.Sleep(3 * time.Second) + } +} + +func exactIP(urll string) string { + u, _ := url.Parse(urll) + host, _, err := net.SplitHostPort(u.Host) + if err != nil { + host = u.Host + } + if strings.HasSuffix(host, ":") { + host = host[0 : len(host)-1] + } + return host +} diff --git a/tools/component/go.mod b/tools/component/go.mod new file mode 100644 index 000000000..bc7abc133 --- /dev/null +++ b/tools/component/go.mod @@ -0,0 +1,3 @@ +module github.com/OpenIMSDK/Open-IM-Server/tools/component + +go 1.19 From 9c86f70408328b34d9546248656743a65afb80e8 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 12:23:10 +0800 Subject: [PATCH 02/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/check_component.go | 160 ----------------- tools/component/main.go | 269 +++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+), 160 deletions(-) delete mode 100644 tools/component/check_component.go create mode 100644 tools/component/main.go diff --git a/tools/component/check_component.go b/tools/component/check_component.go deleted file mode 100644 index 93461f640..000000000 --- a/tools/component/check_component.go +++ /dev/null @@ -1,160 +0,0 @@ -package main - -import ( - "context" - "database/sql" - "fmt" - "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" - "github.com/OpenIMSDK/tools/utils" - "github.com/Shopify/sarama" - "github.com/go-zookeeper/zk" - "github.com/minio/minio-go/v7" - "github.com/redis/go-redis/v9" - "go.mongodb.org/mongo-driver/mongo/readpref" - "net" - "net/url" - "strings" - "time" - - "github.com/minio/minio-go/v7/pkg/credentials" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" -) - -const ( - sqlDriver = "mysql" - minioHealthCheckDuration = 1 - maxRetry = 3 -) - -func main() { - - for i := 0; i < maxRetry; i++ { - success := 1 - // Check MySQL - db, err := sql.Open(sqlDriver, fmt.Sprintf("%s:%s@tcp(%s)/", - config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address)) - if err != nil { - fmt.Printf("Cannot connect to MySQL: %v", err) - success = 0 - } - err = db.Ping() - if err != nil { - fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) - success = 0 - } - db.Close() - - // Check MongoDB - client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( - fmt.Sprintf("mongodb://%s:%s@%s", - config.Config.Mongo.Username, config.Config.Mongo.Password, config.Config.Mongo.Address))) - if err != nil { - fmt.Printf("Cannot connect to MongoDB: %v", err) - success = 0 - } - err = client.Ping(context.TODO(), &readpref.ReadPref{}) - if err != nil { - fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) - success = 0 - } - client.Disconnect(context.TODO()) - - // Check Minio - if config.Config.Object.Enable == "minio" { - if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" && config.Config.Object.ApiURL == config.Config.Object.Minio.Endpoint { - fmt.Printf("ApiURL contain the same address with Endpoint: %v. please modify the config file", config.Config.Object.ApiURL) - } - minioClient, err := minio.New(config.Config.Object.Minio.Endpoint, &minio.Options{ - Creds: credentials.NewStaticV4(config.Config.Object.Minio.AccessKeyID, config.Config.Object.Minio.SecretAccessKey, ""), - Secure: false, - }) - if err != nil { - fmt.Printf("Cannot connect to Minio: %v", err) - success = 0 - } - cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration)) - if err != nil { - fmt.Printf("starting minio health check failed:%v", err) - success = 0 - } - if minioClient.IsOffline() { - fmt.Printf("Error: minio server is offline.") - success = 0 - } - cancel() - } - - // Check Redis - var redisClient redis.UniversalClient - if len(config.Config.Redis.Address) > 1 { - redisClient = redis.NewClusterClient(&redis.ClusterOptions{ - Addrs: config.Config.Redis.Address, - Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, - }) - } else { - redisClient = redis.NewClient(&redis.Options{ - Addr: config.Config.Redis.Address[0], - Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, - }) - } - _, err = redisClient.Ping(context.Background()).Result() - if err != nil { - fmt.Printf("Cannot connect to Redis: %v", err) - success = 0 - } - - // Check Zookeeper - c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) - if err != nil { - fmt.Printf("Cannot connect to Zookeeper: %v", err) - success = 0 - } - c.Close() - - // Check Kafka - kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, &sarama.Config{}) - if err != nil { - fmt.Printf("Cannot connect to Kafka: %v", err) - success = 0 - } else { - topics, err := kafkaClient.Topics() - if err != nil { - fmt.Println("get kafka topic error") - success = 0 - } - if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { - fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic) - success = 0 - } - if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { - fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic) - success = 0 - } - if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { - fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic) - success = 0 - } - } - kafkaClient.Close() - if success == 1 { - fmt.Println("all compose check pass") - return - } - time.Sleep(3 * time.Second) - } -} - -func exactIP(urll string) string { - u, _ := url.Parse(urll) - host, _, err := net.SplitHostPort(u.Host) - if err != nil { - host = u.Host - } - if strings.HasSuffix(host, ":") { - host = host[0 : len(host)-1] - } - return host -} diff --git a/tools/component/main.go b/tools/component/main.go new file mode 100644 index 000000000..306105fa3 --- /dev/null +++ b/tools/component/main.go @@ -0,0 +1,269 @@ +package main + +import ( + "context" + "fmt" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/tools/errs" + "github.com/OpenIMSDK/tools/utils" + "github.com/Shopify/sarama" + "github.com/go-zookeeper/zk" + "github.com/minio/minio-go/v7" + "github.com/redis/go-redis/v9" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/mongo/readpref" + "gopkg.in/yaml.v2" + "gorm.io/driver/mysql" + "gorm.io/gorm" + "net" + "net/url" + "os" + "strings" + "time" + + "github.com/minio/minio-go/v7/pkg/credentials" +) + +const ( + cfgPath = "../../../config/config.yaml" + minioHealthCheckDuration = 1 + maxRetry = 3 + componentStartErr = 1705 +) + +var ( + ErrComponentStart = errs.NewCodeError(componentStartErr, "ComponentStartErr") +) + +func initCfg() error { + data, err := os.ReadFile(cfgPath) + if err != nil { + return err + } + if err = yaml.Unmarshal(data, &config.Config); err != nil { + return err + } + return nil +} + +func main() { + err := initCfg() + if err != nil { + fmt.Printf("Read config failed: %v", err.Error()) + } + for i := 0; i < maxRetry; i++ { + if i != 0 { + time.Sleep(3 * time.Second) + } + fmt.Printf("Checking components Round %v......\n", i+1) + // Check MySQL + if err := checkMysql(); err != nil { + errorPrint(fmt.Sprintf("Starting Mysql failed: %v.Please make sure your mysql service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Mysql starts successfully")) + } + + // Check MongoDB + if err := checkMongo(); err != nil { + errorPrint(fmt.Sprintf("Starting Mongo failed: %v.Please make sure your monngo service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Mongo starts successfully")) + } + + // Check Minio + if err := checkMinio(); err != nil { + errorPrint(fmt.Sprintf("Starting Minio failed: %v.Please make sure your Minio service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Minio starts successfully")) + } + // Check Redis + if err := checkRedis(); err != nil { + errorPrint(fmt.Sprintf("Starting Redis failed: %v.Please make sure your Redis service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Redis starts successfully")) + } + + // Check Zookeeper + if err := checkZookeeper(); err != nil { + errorPrint(fmt.Sprintf("Starting Zookeeper failed: %v.Please make sure your Zookeeper service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Zookeeper starts successfully")) + } + + // Check Kafka + if err := checkKafka(); err != nil { + errorPrint(fmt.Sprintf("Starting Kafka failed: %v.Please make sure your Kafka service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Kafka starts successfully")) + } + successPrint(fmt.Sprint("All components starts successfully")) + break + } +} + +func exactIP(urll string) string { + u, _ := url.Parse(urll) + host, _, err := net.SplitHostPort(u.Host) + if err != nil { + host = u.Host + } + if strings.HasSuffix(host, ":") { + host = host[0 : len(host)-1] + } + return host +} + +func checkMysql() error { + dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", + 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 + } else { + sqlDB, err := db.DB() + err = sqlDB.Ping() + sqlDB.Close() + if err != nil { + return err + } + } + return nil +} + +func checkMongo() error { + mongodbHosts := "" + for i, v := range config.Config.Mongo.Address { + if i == len(config.Config.Mongo.Address)-1 { + mongodbHosts += v + } else { + mongodbHosts += v + "," + } + } + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( + fmt.Sprintf("mongodb://%v:%v@%v/?authSource=admin", + config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts))) + if err != nil { + return err + } else { + err = client.Ping(context.TODO(), &readpref.ReadPref{}) + client.Disconnect(context.TODO()) + if err != nil { + return err + } + } + return nil +} + +func checkMinio() error { + if config.Config.Object.Enable == "minio" { + if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.Endpoint) == "127.0.0.1" { + return ErrComponentStart.Wrap("apiURL or endpoint contain 127.0.0.1. Please modify your config file") + } + conf := config.Config.Object.Minio + u, _ := url.Parse(conf.Endpoint) + minioClient, err := minio.New(u.Host, &minio.Options{ + Creds: credentials.NewStaticV4(conf.AccessKeyID, conf.SecretAccessKey, ""), + Secure: u.Scheme == "https", + }) + if err != nil { + return err + } + + cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration) * time.Second) + if err != nil { + return err + } else { + if minioClient.IsOffline() { + return ErrComponentStart.Wrap("Minio server is offline") + } + cancel() + } + } + return nil +} + +func checkRedis() error { + var redisClient redis.UniversalClient + if len(config.Config.Redis.Address) > 1 { + redisClient = redis.NewClusterClient(&redis.ClusterOptions{ + Addrs: config.Config.Redis.Address, + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } else { + redisClient = redis.NewClient(&redis.Options{ + Addr: config.Config.Redis.Address[0], + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } + _, err := redisClient.Ping(context.Background()).Result() + if err != nil { + return err + } + return nil +} + +func checkZookeeper() error { + c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) + if err != nil { + return 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 { + c.Close() + return err + } + } + _, _, err = c.Get("/") + if err != nil { + c.Close() + return err + } + } + return nil +} + +func checkKafka() error { + cfg := sarama.NewConfig() + if config.Config.Kafka.Username != "" && config.Config.Kafka.Password != "" { + cfg.Net.SASL.Enable = true + cfg.Net.SASL.User = config.Config.Kafka.Username + cfg.Net.SASL.Password = config.Config.Kafka.Password + } + kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, cfg) + if err != nil { + return err + } else { + topics, err := kafkaClient.Topics() + kafkaClient.Close() + if err != nil { + return err + } + if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic)) + } + if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic)) + } + if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic)) + } + } + return nil +} + +func errorPrint(s string) { + fmt.Printf("\x1b[%dm%v\x1b[0m\n", 31, s) +} + +func successPrint(s string) { + fmt.Printf("\x1b[%dm%v\x1b[0m\n", 32, s) +} From 3e312a58ecd4270ca54849bd02018535abba69d0 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 15:27:57 +0800 Subject: [PATCH 03/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index 306105fa3..618c3e2be 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -26,7 +26,7 @@ import ( ) const ( - cfgPath = "../../../config/config.yaml" + cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 maxRetry = 3 componentStartErr = 1705 From e2bf7845c3c801709d1b145d698edacb6ff395f8 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 18:40:00 +0800 Subject: [PATCH 04/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 1 + scripts/path_info.sh | 18 ++++++++++++ scripts/start_component_check.sh | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 scripts/start_component_check.sh diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index f617c5057..28fc86462 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -23,6 +23,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #fixme Put the shell scripts name here need_to_start_server_shell=( + ${SCRIPTS_ROOT}/start_component_check.sh ${SCRIPTS_ROOT}/start_rpc_service.sh ${SCRIPTS_ROOT}/msg_gateway_start.sh ${SCRIPTS_ROOT}/push_start.sh diff --git a/scripts/path_info.sh b/scripts/path_info.sh index d3f6f4e1c..c56d10d79 100755 --- a/scripts/path_info.sh +++ b/scripts/path_info.sh @@ -40,6 +40,19 @@ declare -A supported_architectures=( ["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64 ) +declare -A supported_architectures_tools=( + ["linux-amd64"]="_output/bin-tools/platforms/linux/amd64" + ["linux-arm64"]="_output/bin-tools/platforms/linux/arm64" + ["linux-mips64"]="_output/bin-tools/platforms/linux/mips64" + ["linux-mips64le"]="_output/bin-tools/platforms/linux/mips64le" + ["linux-ppc64le"]="_output/bin-tools/platforms/linux/ppc64le" + ["linux-s390x"]="_output/bin-tools/platforms/linux/s390x" + ["darwin-amd64"]="_output/bin-tools/platforms/darwin/amd64" + ["windows-amd64"]="_output/bin-tools/platforms/windows/amd64" + ["linux-x86_64"]="_output/bin-tools/platforms/linux/amd64" # Alias for linux-amd64 + ["darwin-x86_64"]="_output/bin-tools/platforms/darwin/amd64" # Alias for darwin-amd64 +) + # Check if the architecture and version are supported if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then echo -e "${BLUE_PREFIX}================> Unsupported architecture: $architecture or version: $version${COLOR_SUFFIX}" @@ -50,6 +63,7 @@ echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFF # Set the BIN_DIR based on the architecture and version BIN_DIR=${supported_architectures["$version-$architecture"]} +BIN_DIR_TOOLS=${supported_architectures["$version-$architecture"]} echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}" @@ -84,6 +98,10 @@ config_path="$OPENIM_ROOT/config/config.yaml" configfile_path="$OPENIM_ROOT/config" log_path="$OPENIM_ROOT/log" + +component_check="component" +component_check_binary_root="$OPENIM_ROOT/$BIN_DIR_TOOLS" + # servicefile dir path service_source_root=( # api service file diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh new file mode 100644 index 000000000..9dbacb5b9 --- /dev/null +++ b/scripts/start_component_check.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. + +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" + +bin_dir="$BIN_DIR" +logs_dir="$OPENIM_ROOT/logs" + +cd $OPENIM_ROOT + +#Check if the service exists +#If it is exists,kill this process +check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +oldPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 + +cd ${component_check_binary_root} +cmd="nohup ./${component_check}" +echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log +$cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 & + + From 85a1e35555ef72b8cf46b88913a193d4672314f6 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 11:59:57 +0800 Subject: [PATCH 05/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- go.mod | 2 +- go.work | 3 +- tools/component/check_component.go | 160 +++++++++++++++++++++++++++++ tools/component/go.mod | 3 + 4 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 tools/component/check_component.go create mode 100644 tools/component/go.mod diff --git a/go.mod b/go.mod index 20f6c72e0..af675ac59 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,7 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible github.com/go-redis/redis v6.15.9+incompatible github.com/go-sql-driver/mysql v1.7.1 + github.com/go-zookeeper/zk v1.0.3 github.com/redis/go-redis/v9 v9.0.5 github.com/tencentyun/cos-go-sdk-v5 v0.7.42 ) @@ -68,7 +69,6 @@ require ( github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-zookeeper/zk v1.0.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.5.9 // indirect diff --git a/go.work b/go.work index 09e86f032..757933536 100644 --- a/go.work +++ b/go.work @@ -1,7 +1,8 @@ go 1.20 use ( - . + . + ./tools/component ./tools/infra ./tools/ncpu ) diff --git a/tools/component/check_component.go b/tools/component/check_component.go new file mode 100644 index 000000000..93461f640 --- /dev/null +++ b/tools/component/check_component.go @@ -0,0 +1,160 @@ +package main + +import ( + "context" + "database/sql" + "fmt" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/tools/utils" + "github.com/Shopify/sarama" + "github.com/go-zookeeper/zk" + "github.com/minio/minio-go/v7" + "github.com/redis/go-redis/v9" + "go.mongodb.org/mongo-driver/mongo/readpref" + "net" + "net/url" + "strings" + "time" + + "github.com/minio/minio-go/v7/pkg/credentials" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +const ( + sqlDriver = "mysql" + minioHealthCheckDuration = 1 + maxRetry = 3 +) + +func main() { + + for i := 0; i < maxRetry; i++ { + success := 1 + // Check MySQL + db, err := sql.Open(sqlDriver, fmt.Sprintf("%s:%s@tcp(%s)/", + config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address)) + if err != nil { + fmt.Printf("Cannot connect to MySQL: %v", err) + success = 0 + } + err = db.Ping() + if err != nil { + fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) + success = 0 + } + db.Close() + + // Check MongoDB + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( + fmt.Sprintf("mongodb://%s:%s@%s", + config.Config.Mongo.Username, config.Config.Mongo.Password, config.Config.Mongo.Address))) + if err != nil { + fmt.Printf("Cannot connect to MongoDB: %v", err) + success = 0 + } + err = client.Ping(context.TODO(), &readpref.ReadPref{}) + if err != nil { + fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) + success = 0 + } + client.Disconnect(context.TODO()) + + // Check Minio + if config.Config.Object.Enable == "minio" { + if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" && config.Config.Object.ApiURL == config.Config.Object.Minio.Endpoint { + fmt.Printf("ApiURL contain the same address with Endpoint: %v. please modify the config file", config.Config.Object.ApiURL) + } + minioClient, err := minio.New(config.Config.Object.Minio.Endpoint, &minio.Options{ + Creds: credentials.NewStaticV4(config.Config.Object.Minio.AccessKeyID, config.Config.Object.Minio.SecretAccessKey, ""), + Secure: false, + }) + if err != nil { + fmt.Printf("Cannot connect to Minio: %v", err) + success = 0 + } + cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration)) + if err != nil { + fmt.Printf("starting minio health check failed:%v", err) + success = 0 + } + if minioClient.IsOffline() { + fmt.Printf("Error: minio server is offline.") + success = 0 + } + cancel() + } + + // Check Redis + var redisClient redis.UniversalClient + if len(config.Config.Redis.Address) > 1 { + redisClient = redis.NewClusterClient(&redis.ClusterOptions{ + Addrs: config.Config.Redis.Address, + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } else { + redisClient = redis.NewClient(&redis.Options{ + Addr: config.Config.Redis.Address[0], + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } + _, err = redisClient.Ping(context.Background()).Result() + if err != nil { + fmt.Printf("Cannot connect to Redis: %v", err) + success = 0 + } + + // Check Zookeeper + c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) + if err != nil { + fmt.Printf("Cannot connect to Zookeeper: %v", err) + success = 0 + } + c.Close() + + // Check Kafka + kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, &sarama.Config{}) + if err != nil { + fmt.Printf("Cannot connect to Kafka: %v", err) + success = 0 + } else { + topics, err := kafkaClient.Topics() + if err != nil { + fmt.Println("get kafka topic error") + success = 0 + } + if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { + fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic) + success = 0 + } + if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { + fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic) + success = 0 + } + if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { + fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic) + success = 0 + } + } + kafkaClient.Close() + if success == 1 { + fmt.Println("all compose check pass") + return + } + time.Sleep(3 * time.Second) + } +} + +func exactIP(urll string) string { + u, _ := url.Parse(urll) + host, _, err := net.SplitHostPort(u.Host) + if err != nil { + host = u.Host + } + if strings.HasSuffix(host, ":") { + host = host[0 : len(host)-1] + } + return host +} diff --git a/tools/component/go.mod b/tools/component/go.mod new file mode 100644 index 000000000..bc7abc133 --- /dev/null +++ b/tools/component/go.mod @@ -0,0 +1,3 @@ +module github.com/OpenIMSDK/Open-IM-Server/tools/component + +go 1.19 From eb33487367c58ba6ef1e3dffca0110ee2d74fe54 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 12:23:10 +0800 Subject: [PATCH 06/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/check_component.go | 160 ----------------- tools/component/main.go | 269 +++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+), 160 deletions(-) delete mode 100644 tools/component/check_component.go create mode 100644 tools/component/main.go diff --git a/tools/component/check_component.go b/tools/component/check_component.go deleted file mode 100644 index 93461f640..000000000 --- a/tools/component/check_component.go +++ /dev/null @@ -1,160 +0,0 @@ -package main - -import ( - "context" - "database/sql" - "fmt" - "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" - "github.com/OpenIMSDK/tools/utils" - "github.com/Shopify/sarama" - "github.com/go-zookeeper/zk" - "github.com/minio/minio-go/v7" - "github.com/redis/go-redis/v9" - "go.mongodb.org/mongo-driver/mongo/readpref" - "net" - "net/url" - "strings" - "time" - - "github.com/minio/minio-go/v7/pkg/credentials" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" -) - -const ( - sqlDriver = "mysql" - minioHealthCheckDuration = 1 - maxRetry = 3 -) - -func main() { - - for i := 0; i < maxRetry; i++ { - success := 1 - // Check MySQL - db, err := sql.Open(sqlDriver, fmt.Sprintf("%s:%s@tcp(%s)/", - config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address)) - if err != nil { - fmt.Printf("Cannot connect to MySQL: %v", err) - success = 0 - } - err = db.Ping() - if err != nil { - fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) - success = 0 - } - db.Close() - - // Check MongoDB - client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( - fmt.Sprintf("mongodb://%s:%s@%s", - config.Config.Mongo.Username, config.Config.Mongo.Password, config.Config.Mongo.Address))) - if err != nil { - fmt.Printf("Cannot connect to MongoDB: %v", err) - success = 0 - } - err = client.Ping(context.TODO(), &readpref.ReadPref{}) - if err != nil { - fmt.Printf("ping mysql failed: %v. please make sure your mysql service has started", err) - success = 0 - } - client.Disconnect(context.TODO()) - - // Check Minio - if config.Config.Object.Enable == "minio" { - if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" && config.Config.Object.ApiURL == config.Config.Object.Minio.Endpoint { - fmt.Printf("ApiURL contain the same address with Endpoint: %v. please modify the config file", config.Config.Object.ApiURL) - } - minioClient, err := minio.New(config.Config.Object.Minio.Endpoint, &minio.Options{ - Creds: credentials.NewStaticV4(config.Config.Object.Minio.AccessKeyID, config.Config.Object.Minio.SecretAccessKey, ""), - Secure: false, - }) - if err != nil { - fmt.Printf("Cannot connect to Minio: %v", err) - success = 0 - } - cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration)) - if err != nil { - fmt.Printf("starting minio health check failed:%v", err) - success = 0 - } - if minioClient.IsOffline() { - fmt.Printf("Error: minio server is offline.") - success = 0 - } - cancel() - } - - // Check Redis - var redisClient redis.UniversalClient - if len(config.Config.Redis.Address) > 1 { - redisClient = redis.NewClusterClient(&redis.ClusterOptions{ - Addrs: config.Config.Redis.Address, - Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, - }) - } else { - redisClient = redis.NewClient(&redis.Options{ - Addr: config.Config.Redis.Address[0], - Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, - }) - } - _, err = redisClient.Ping(context.Background()).Result() - if err != nil { - fmt.Printf("Cannot connect to Redis: %v", err) - success = 0 - } - - // Check Zookeeper - c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) - if err != nil { - fmt.Printf("Cannot connect to Zookeeper: %v", err) - success = 0 - } - c.Close() - - // Check Kafka - kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, &sarama.Config{}) - if err != nil { - fmt.Printf("Cannot connect to Kafka: %v", err) - success = 0 - } else { - topics, err := kafkaClient.Topics() - if err != nil { - fmt.Println("get kafka topic error") - success = 0 - } - if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { - fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic) - success = 0 - } - if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { - fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic) - success = 0 - } - if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { - fmt.Printf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic) - success = 0 - } - } - kafkaClient.Close() - if success == 1 { - fmt.Println("all compose check pass") - return - } - time.Sleep(3 * time.Second) - } -} - -func exactIP(urll string) string { - u, _ := url.Parse(urll) - host, _, err := net.SplitHostPort(u.Host) - if err != nil { - host = u.Host - } - if strings.HasSuffix(host, ":") { - host = host[0 : len(host)-1] - } - return host -} diff --git a/tools/component/main.go b/tools/component/main.go new file mode 100644 index 000000000..306105fa3 --- /dev/null +++ b/tools/component/main.go @@ -0,0 +1,269 @@ +package main + +import ( + "context" + "fmt" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" + "github.com/OpenIMSDK/tools/errs" + "github.com/OpenIMSDK/tools/utils" + "github.com/Shopify/sarama" + "github.com/go-zookeeper/zk" + "github.com/minio/minio-go/v7" + "github.com/redis/go-redis/v9" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/mongo/readpref" + "gopkg.in/yaml.v2" + "gorm.io/driver/mysql" + "gorm.io/gorm" + "net" + "net/url" + "os" + "strings" + "time" + + "github.com/minio/minio-go/v7/pkg/credentials" +) + +const ( + cfgPath = "../../../config/config.yaml" + minioHealthCheckDuration = 1 + maxRetry = 3 + componentStartErr = 1705 +) + +var ( + ErrComponentStart = errs.NewCodeError(componentStartErr, "ComponentStartErr") +) + +func initCfg() error { + data, err := os.ReadFile(cfgPath) + if err != nil { + return err + } + if err = yaml.Unmarshal(data, &config.Config); err != nil { + return err + } + return nil +} + +func main() { + err := initCfg() + if err != nil { + fmt.Printf("Read config failed: %v", err.Error()) + } + for i := 0; i < maxRetry; i++ { + if i != 0 { + time.Sleep(3 * time.Second) + } + fmt.Printf("Checking components Round %v......\n", i+1) + // Check MySQL + if err := checkMysql(); err != nil { + errorPrint(fmt.Sprintf("Starting Mysql failed: %v.Please make sure your mysql service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Mysql starts successfully")) + } + + // Check MongoDB + if err := checkMongo(); err != nil { + errorPrint(fmt.Sprintf("Starting Mongo failed: %v.Please make sure your monngo service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Mongo starts successfully")) + } + + // Check Minio + if err := checkMinio(); err != nil { + errorPrint(fmt.Sprintf("Starting Minio failed: %v.Please make sure your Minio service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Minio starts successfully")) + } + // Check Redis + if err := checkRedis(); err != nil { + errorPrint(fmt.Sprintf("Starting Redis failed: %v.Please make sure your Redis service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Redis starts successfully")) + } + + // Check Zookeeper + if err := checkZookeeper(); err != nil { + errorPrint(fmt.Sprintf("Starting Zookeeper failed: %v.Please make sure your Zookeeper service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Zookeeper starts successfully")) + } + + // Check Kafka + if err := checkKafka(); err != nil { + errorPrint(fmt.Sprintf("Starting Kafka failed: %v.Please make sure your Kafka service has started", err.Error())) + continue + } else { + successPrint(fmt.Sprint("Kafka starts successfully")) + } + successPrint(fmt.Sprint("All components starts successfully")) + break + } +} + +func exactIP(urll string) string { + u, _ := url.Parse(urll) + host, _, err := net.SplitHostPort(u.Host) + if err != nil { + host = u.Host + } + if strings.HasSuffix(host, ":") { + host = host[0 : len(host)-1] + } + return host +} + +func checkMysql() error { + dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", + 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 + } else { + sqlDB, err := db.DB() + err = sqlDB.Ping() + sqlDB.Close() + if err != nil { + return err + } + } + return nil +} + +func checkMongo() error { + mongodbHosts := "" + for i, v := range config.Config.Mongo.Address { + if i == len(config.Config.Mongo.Address)-1 { + mongodbHosts += v + } else { + mongodbHosts += v + "," + } + } + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI( + fmt.Sprintf("mongodb://%v:%v@%v/?authSource=admin", + config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts))) + if err != nil { + return err + } else { + err = client.Ping(context.TODO(), &readpref.ReadPref{}) + client.Disconnect(context.TODO()) + if err != nil { + return err + } + } + return nil +} + +func checkMinio() error { + if config.Config.Object.Enable == "minio" { + if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.Endpoint) == "127.0.0.1" { + return ErrComponentStart.Wrap("apiURL or endpoint contain 127.0.0.1. Please modify your config file") + } + conf := config.Config.Object.Minio + u, _ := url.Parse(conf.Endpoint) + minioClient, err := minio.New(u.Host, &minio.Options{ + Creds: credentials.NewStaticV4(conf.AccessKeyID, conf.SecretAccessKey, ""), + Secure: u.Scheme == "https", + }) + if err != nil { + return err + } + + cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration) * time.Second) + if err != nil { + return err + } else { + if minioClient.IsOffline() { + return ErrComponentStart.Wrap("Minio server is offline") + } + cancel() + } + } + return nil +} + +func checkRedis() error { + var redisClient redis.UniversalClient + if len(config.Config.Redis.Address) > 1 { + redisClient = redis.NewClusterClient(&redis.ClusterOptions{ + Addrs: config.Config.Redis.Address, + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } else { + redisClient = redis.NewClient(&redis.Options{ + Addr: config.Config.Redis.Address[0], + Username: config.Config.Redis.Username, + Password: config.Config.Redis.Password, + }) + } + _, err := redisClient.Ping(context.Background()).Result() + if err != nil { + return err + } + return nil +} + +func checkZookeeper() error { + c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) + if err != nil { + return 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 { + c.Close() + return err + } + } + _, _, err = c.Get("/") + if err != nil { + c.Close() + return err + } + } + return nil +} + +func checkKafka() error { + cfg := sarama.NewConfig() + if config.Config.Kafka.Username != "" && config.Config.Kafka.Password != "" { + cfg.Net.SASL.Enable = true + cfg.Net.SASL.User = config.Config.Kafka.Username + cfg.Net.SASL.Password = config.Config.Kafka.Password + } + kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, cfg) + if err != nil { + return err + } else { + topics, err := kafkaClient.Topics() + kafkaClient.Close() + if err != nil { + return err + } + if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic)) + } + if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic)) + } + if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic)) + } + } + return nil +} + +func errorPrint(s string) { + fmt.Printf("\x1b[%dm%v\x1b[0m\n", 31, s) +} + +func successPrint(s string) { + fmt.Printf("\x1b[%dm%v\x1b[0m\n", 32, s) +} From 5c3f7a91078471806c1bb74acb789986d07f6011 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 15:27:57 +0800 Subject: [PATCH 07/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index 306105fa3..618c3e2be 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -26,7 +26,7 @@ import ( ) const ( - cfgPath = "../../../config/config.yaml" + cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 maxRetry = 3 componentStartErr = 1705 From 69fbc17082dd3fbcaf3335c7d32c2934adf75749 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Tue, 8 Aug 2023 18:40:00 +0800 Subject: [PATCH 08/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 1 + scripts/path_info.sh | 18 ++++++++++++ scripts/start_component_check.sh | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 scripts/start_component_check.sh diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index f617c5057..28fc86462 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -23,6 +23,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #fixme Put the shell scripts name here need_to_start_server_shell=( + ${SCRIPTS_ROOT}/start_component_check.sh ${SCRIPTS_ROOT}/start_rpc_service.sh ${SCRIPTS_ROOT}/msg_gateway_start.sh ${SCRIPTS_ROOT}/push_start.sh diff --git a/scripts/path_info.sh b/scripts/path_info.sh index d3f6f4e1c..c56d10d79 100755 --- a/scripts/path_info.sh +++ b/scripts/path_info.sh @@ -40,6 +40,19 @@ declare -A supported_architectures=( ["darwin-x86_64"]="_output/bin/platforms/darwin/amd64" # Alias for darwin-amd64 ) +declare -A supported_architectures_tools=( + ["linux-amd64"]="_output/bin-tools/platforms/linux/amd64" + ["linux-arm64"]="_output/bin-tools/platforms/linux/arm64" + ["linux-mips64"]="_output/bin-tools/platforms/linux/mips64" + ["linux-mips64le"]="_output/bin-tools/platforms/linux/mips64le" + ["linux-ppc64le"]="_output/bin-tools/platforms/linux/ppc64le" + ["linux-s390x"]="_output/bin-tools/platforms/linux/s390x" + ["darwin-amd64"]="_output/bin-tools/platforms/darwin/amd64" + ["windows-amd64"]="_output/bin-tools/platforms/windows/amd64" + ["linux-x86_64"]="_output/bin-tools/platforms/linux/amd64" # Alias for linux-amd64 + ["darwin-x86_64"]="_output/bin-tools/platforms/darwin/amd64" # Alias for darwin-amd64 +) + # Check if the architecture and version are supported if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then echo -e "${BLUE_PREFIX}================> Unsupported architecture: $architecture or version: $version${COLOR_SUFFIX}" @@ -50,6 +63,7 @@ echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFF # Set the BIN_DIR based on the architecture and version BIN_DIR=${supported_architectures["$version-$architecture"]} +BIN_DIR_TOOLS=${supported_architectures["$version-$architecture"]} echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}" @@ -84,6 +98,10 @@ config_path="$OPENIM_ROOT/config/config.yaml" configfile_path="$OPENIM_ROOT/config" log_path="$OPENIM_ROOT/log" + +component_check="component" +component_check_binary_root="$OPENIM_ROOT/$BIN_DIR_TOOLS" + # servicefile dir path service_source_root=( # api service file diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh new file mode 100644 index 000000000..9dbacb5b9 --- /dev/null +++ b/scripts/start_component_check.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. + +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +echo -e "${YELLOW_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" + +bin_dir="$BIN_DIR" +logs_dir="$OPENIM_ROOT/logs" + +cd $OPENIM_ROOT + +#Check if the service exists +#If it is exists,kill this process +check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` +if [ $check -ge 1 ] +then +oldPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 + +cd ${component_check_binary_root} +cmd="nohup ./${component_check}" +echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log +$cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 & + + From 2c7bbd9f053a5cca7c87f41fb53de2ab027db4db Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 09:58:56 +0800 Subject: [PATCH 09/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_all.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index b6b4e3428..3b526006a 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -70,6 +70,7 @@ cd $SCRIPTS_ROOT # FIXME Put the shell script names here need_to_start_server_shell=( + start_component_check.sh start_rpc_service.sh push_start.sh msg_transfer_start.sh From ad5129b8d606074ad1c17ea9639669aa5c714a9c Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 10:08:59 +0800 Subject: [PATCH 10/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_component_check.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index 9dbacb5b9..c1472448e 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -29,19 +29,6 @@ echo -e "${YELLOW_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" -cd $OPENIM_ROOT - -#Check if the service exists -#If it is exists,kill this process -check=`ps | grep -w ./${openim_msgtransfer} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps | grep -w ./${openim_msgtransfer} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 - cd ${component_check_binary_root} cmd="nohup ./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log From 92904f2e2f0410e81ed9525b03e8fc06457f24df Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 10:22:12 +0800 Subject: [PATCH 11/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_component_check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index c1472448e..6b91b4570 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -30,6 +30,7 @@ bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" cd ${component_check_binary_root} +echo -e "${YELLOW_PREFIX}=======>$PWD${COLOR_SUFFIX}" cmd="nohup ./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 & From f0b7f074a6ab53b639ce9d0086bff7545cc80a2c Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 10:25:59 +0800 Subject: [PATCH 12/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/path_info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/path_info.sh b/scripts/path_info.sh index c56d10d79..7ba33ca2c 100755 --- a/scripts/path_info.sh +++ b/scripts/path_info.sh @@ -63,7 +63,7 @@ echo -e "${BLUE_PREFIX}================> Architecture: $architecture${COLOR_SUFF # Set the BIN_DIR based on the architecture and version BIN_DIR=${supported_architectures["$version-$architecture"]} -BIN_DIR_TOOLS=${supported_architectures["$version-$architecture"]} +BIN_DIR_TOOLS=${supported_architectures_tools["$version-$architecture"]} echo -e "${BLUE_PREFIX}================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR${COLOR_SUFFIX}" From c2295b03225ebc2f9afecc12eb48ce8aabdcbb50 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 10:31:16 +0800 Subject: [PATCH 13/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_component_check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index 6b91b4570..8e1f688ca 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -33,6 +33,6 @@ cd ${component_check_binary_root} echo -e "${YELLOW_PREFIX}=======>$PWD${COLOR_SUFFIX}" cmd="nohup ./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log -$cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 & +$cmd From 399e98ef5d09508362f7345a44deaa5bbc5560dd Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 10:40:59 +0800 Subject: [PATCH 14/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 1 - scripts/start_component_check.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 28fc86462..f617c5057 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -23,7 +23,6 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #fixme Put the shell scripts name here need_to_start_server_shell=( - ${SCRIPTS_ROOT}/start_component_check.sh ${SCRIPTS_ROOT}/start_rpc_service.sh ${SCRIPTS_ROOT}/msg_gateway_start.sh ${SCRIPTS_ROOT}/push_start.sh diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index 8e1f688ca..f0358c6f9 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -31,7 +31,7 @@ logs_dir="$OPENIM_ROOT/logs" cd ${component_check_binary_root} echo -e "${YELLOW_PREFIX}=======>$PWD${COLOR_SUFFIX}" -cmd="nohup ./${component_check}" +cmd="./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd From f5ea9fcfb459726fc2c06f1a021deaa75796411f Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 11:01:07 +0800 Subject: [PATCH 15/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index 618c3e2be..5c05a9f85 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -29,11 +29,13 @@ const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 maxRetry = 3 - componentStartErr = 1705 + componentStartErrCode = 6000 + configErrCode = 6001 ) var ( ErrComponentStart = errs.NewCodeError(componentStartErr, "ComponentStartErr") + Errconfig = errs.NewCodeError(configErr, "") ) func initCfg() error { From 2a3f4225f3e831e2c834de949166ec55466b747d Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 11:26:59 +0800 Subject: [PATCH 16/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/component/main.go b/tools/component/main.go index 5c05a9f85..88c37a438 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -34,8 +34,8 @@ const ( ) var ( - ErrComponentStart = errs.NewCodeError(componentStartErr, "ComponentStartErr") - Errconfig = errs.NewCodeError(configErr, "") + ErrComponentStart = errs.NewCodeError(componentStartErrCode, "ComponentStartErr") + ErrConfig = errs.NewCodeError(configErrCode, "Config file is incorrect") ) func initCfg() error { @@ -77,7 +77,11 @@ func main() { // Check Minio if err := checkMinio(); err != nil { - errorPrint(fmt.Sprintf("Starting Minio failed: %v.Please make sure your Minio service has started", err.Error())) + if index := strings.Index(err.Error(), utils.IntToString(configErrCode)); index != -1 { + warningPrint(fmt.Sprintf("%v Please modify your config file", err.Error())) + } else { + errorPrint(fmt.Sprintf("Starting Minio failed: %v.Please make sure your Minio service has started", err.Error())) + } continue } else { successPrint(fmt.Sprint("Minio starts successfully")) @@ -166,7 +170,7 @@ func checkMongo() error { func checkMinio() error { if config.Config.Object.Enable == "minio" { if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.Endpoint) == "127.0.0.1" { - return ErrComponentStart.Wrap("apiURL or endpoint contain 127.0.0.1. Please modify your config file") + return ErrConfig.Wrap("apiURL or endpoint contain 127.0.0.1.") } conf := config.Config.Object.Minio u, _ := url.Parse(conf.Endpoint) @@ -269,3 +273,7 @@ func errorPrint(s string) { func successPrint(s string) { fmt.Printf("\x1b[%dm%v\x1b[0m\n", 32, s) } + +func warningPrint(s string) { + fmt.Printf("\x1b[%dmhello world\x1b[0m\n", 33) +} From 29d837a1b72eda0a13448732c9844c98a17fe0b7 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 11:30:39 +0800 Subject: [PATCH 17/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index 88c37a438..0bf4d5f23 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -275,5 +275,5 @@ func successPrint(s string) { } func warningPrint(s string) { - fmt.Printf("\x1b[%dmhello world\x1b[0m\n", 33) + fmt.Printf("\x1b[%dm%v\x1b[0m\n", 33, s) } From cb1d9e0e06345d6b396b7a2c45795b50c1a4ccd4 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 11:34:36 +0800 Subject: [PATCH 18/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/component/main.go b/tools/component/main.go index 0bf4d5f23..adea21a51 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -61,7 +61,7 @@ func main() { fmt.Printf("Checking components Round %v......\n", i+1) // Check MySQL if err := checkMysql(); err != nil { - errorPrint(fmt.Sprintf("Starting Mysql failed: %v.Please make sure your mysql service has started", err.Error())) + errorPrint(fmt.Sprintf("Starting Mysql failed: %v. Please make sure your mysql service has started", err.Error())) continue } else { successPrint(fmt.Sprint("Mysql starts successfully")) @@ -69,7 +69,7 @@ func main() { // Check MongoDB if err := checkMongo(); err != nil { - errorPrint(fmt.Sprintf("Starting Mongo failed: %v.Please make sure your monngo service has started", err.Error())) + errorPrint(fmt.Sprintf("Starting Mongo failed: %v. Please make sure your monngo service has started", err.Error())) continue } else { successPrint(fmt.Sprint("Mongo starts successfully")) @@ -78,9 +78,9 @@ func main() { // Check Minio if err := checkMinio(); err != nil { if index := strings.Index(err.Error(), utils.IntToString(configErrCode)); index != -1 { - warningPrint(fmt.Sprintf("%v Please modify your config file", err.Error())) + warningPrint(fmt.Sprintf("%v. Please modify your config file", err.Error())) } else { - errorPrint(fmt.Sprintf("Starting Minio failed: %v.Please make sure your Minio service has started", err.Error())) + errorPrint(fmt.Sprintf("Starting Minio failed: %v. Please make sure your Minio service has started", err.Error())) } continue } else { @@ -275,5 +275,5 @@ func successPrint(s string) { } func warningPrint(s string) { - fmt.Printf("\x1b[%dm%v\x1b[0m\n", 33, s) + fmt.Printf("\x1b[%dmWarning: %v\x1b[0m\n", 33, s) } From 42dfacb285f979dc967def48f899b13987fbd281 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 11:58:58 +0800 Subject: [PATCH 19/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_component_check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index f0358c6f9..87fb4c762 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -34,5 +34,6 @@ echo -e "${YELLOW_PREFIX}=======>$PWD${COLOR_SUFFIX}" cmd="./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd +exit 1 From e7043a1668b841601e3c2b76c0d377897fc27d0c Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 12:04:56 +0800 Subject: [PATCH 20/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_component_check.sh | 1 - tools/component/main.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index 87fb4c762..f0358c6f9 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -34,6 +34,5 @@ echo -e "${YELLOW_PREFIX}=======>$PWD${COLOR_SUFFIX}" cmd="./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd -exit 1 diff --git a/tools/component/main.go b/tools/component/main.go index adea21a51..fbb4c319b 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -81,8 +81,8 @@ func main() { warningPrint(fmt.Sprintf("%v. Please modify your config file", err.Error())) } else { errorPrint(fmt.Sprintf("Starting Minio failed: %v. Please make sure your Minio service has started", err.Error())) + continue } - continue } else { successPrint(fmt.Sprint("Minio starts successfully")) } From ee8a1570845a3b52f9182991e4adc97f737d9f5a Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 12:14:02 +0800 Subject: [PATCH 21/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index fbb4c319b..3bd0b2420 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -28,7 +28,7 @@ import ( const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 - maxRetry = 3 + maxRetry = 10000 componentStartErrCode = 6000 configErrCode = 6001 ) From afc4e23f65bae4f3b939c72ba3e7aac78b7d96ac Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:12:32 +0800 Subject: [PATCH 22/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_all.sh | 3 ++- scripts/start_component_check.sh | 4 ++++ tools/component/main.go | 8 +++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 3b526006a..fb59d6767 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -70,13 +70,14 @@ cd $SCRIPTS_ROOT # FIXME Put the shell script names here need_to_start_server_shell=( - start_component_check.sh start_rpc_service.sh push_start.sh msg_transfer_start.sh msg_gateway_start.sh start_cron.sh ) + chmod +x $i + start_component_check.sh # Loop through the script names and execute them for i in ${need_to_start_server_shell[*]}; do diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index f0358c6f9..18726ce87 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -35,4 +35,8 @@ cmd="./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd +if [ $? -eq 0 ]; then + exit 1 +fi + diff --git a/tools/component/main.go b/tools/component/main.go index 3bd0b2420..ebc70913d 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -28,7 +28,7 @@ import ( const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 - maxRetry = 10000 + maxRetry = 100 componentStartErrCode = 6000 configErrCode = 6001 ) @@ -78,6 +78,7 @@ func main() { // Check Minio if err := checkMinio(); err != nil { if index := strings.Index(err.Error(), utils.IntToString(configErrCode)); index != -1 { + successPrint(fmt.Sprint("Minio starts successfully")) warningPrint(fmt.Sprintf("%v. Please modify your config file", err.Error())) } else { errorPrint(fmt.Sprintf("Starting Minio failed: %v. Please make sure your Minio service has started", err.Error())) @@ -110,8 +111,9 @@ func main() { successPrint(fmt.Sprint("Kafka starts successfully")) } successPrint(fmt.Sprint("All components starts successfully")) - break + os.Exit(0) } + os.Exit(1) } func exactIP(urll string) string { @@ -275,5 +277,5 @@ func successPrint(s string) { } func warningPrint(s string) { - fmt.Printf("\x1b[%dmWarning: %v\x1b[0m\n", 33, s) + fmt.Printf("\x1b[%dmWarning: But %v\x1b[0m\n", 33, s) } From d72131799126652df3842b2911c01a8928b41d3f Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:19:54 +0800 Subject: [PATCH 23/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_all.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index fb59d6767..7e437e4b6 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -76,8 +76,19 @@ need_to_start_server_shell=( msg_gateway_start.sh start_cron.sh ) - chmod +x $i - start_component_check.sh + +component_check=start_component_check.sh +echo -e "" +chmod +x $component_check +echo -e "=========> ${BACKGROUND_GREEN}Executing ${component_check}...${COLOR_SUFFIX}" +echo -e "" +./start_component_check.sh +if [ $? -ne 0 ]; then + # Print error message and exit + echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + exit -1 +fi + # Loop through the script names and execute them for i in ${need_to_start_server_shell[*]}; do From 6483287659662edd3f72095c1184d8387fd3446f Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:22:09 +0800 Subject: [PATCH 24/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_all.sh | 2 +- scripts/start_component_check.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 7e437e4b6..4e6329af5 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -82,7 +82,7 @@ echo -e "" chmod +x $component_check echo -e "=========> ${BACKGROUND_GREEN}Executing ${component_check}...${COLOR_SUFFIX}" echo -e "" -./start_component_check.sh +./$component_check if [ $? -ne 0 ]; then # Print error message and exit echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index 18726ce87..98ec48dec 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -35,7 +35,7 @@ cmd="./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd -if [ $? -eq 0 ]; then +if [ $? -nq 0 ]; then exit 1 fi From c1f0979f714d2f194a74aeb1804a31f6062c0af1 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:25:36 +0800 Subject: [PATCH 25/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/component/main.go b/tools/component/main.go index ebc70913d..a1a83b8d2 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -28,7 +28,7 @@ import ( const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 - maxRetry = 100 + maxRetry = 10 componentStartErrCode = 6000 configErrCode = 6001 ) @@ -172,7 +172,7 @@ func checkMongo() error { func checkMinio() error { if config.Config.Object.Enable == "minio" { if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.Endpoint) == "127.0.0.1" { - return ErrConfig.Wrap("apiURL or endpoint contain 127.0.0.1.") + return ErrConfig.Wrap("apiURL or Minio endpoint contain 127.0.0.1.") } conf := config.Config.Object.Minio u, _ := url.Parse(conf.Endpoint) From 1b755305cb7bbeeff0b8008c364d0c357a803483 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:31:01 +0800 Subject: [PATCH 26/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_component_check.sh | 2 +- tools/component/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start_component_check.sh b/scripts/start_component_check.sh index 98ec48dec..6d9fa227b 100644 --- a/scripts/start_component_check.sh +++ b/scripts/start_component_check.sh @@ -35,7 +35,7 @@ cmd="./${component_check}" echo "==========================start components checking===========================">>$OPENIM_ROOT/logs/openIM.log $cmd -if [ $? -nq 0 ]; then +if [ $? -ne 0 ]; then exit 1 fi diff --git a/tools/component/main.go b/tools/component/main.go index a1a83b8d2..f9b4c4c79 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -28,7 +28,7 @@ import ( const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 - maxRetry = 10 + maxRetry = 100 componentStartErrCode = 6000 configErrCode = 6001 ) From 2b21083adeebbf665a520ec0d9e08e6eb72b72e9 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:31:21 +0800 Subject: [PATCH 27/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index f9b4c4c79..bde0b6fda 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -28,7 +28,7 @@ import ( const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 - maxRetry = 100 + maxRetry = 3 componentStartErrCode = 6000 configErrCode = 6001 ) From 3038cbfe18ae22933090379b14e443fb8b18b078 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 14:34:14 +0800 Subject: [PATCH 28/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- tools/component/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/main.go b/tools/component/main.go index bde0b6fda..f9b4c4c79 100644 --- a/tools/component/main.go +++ b/tools/component/main.go @@ -28,7 +28,7 @@ import ( const ( cfgPath = "../../../../../config/config.yaml" minioHealthCheckDuration = 1 - maxRetry = 3 + maxRetry = 100 componentStartErrCode = 6000 configErrCode = 6001 ) From 215a0ad6ea01bcce4ebce20b0e098347e68f234b Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 15:03:30 +0800 Subject: [PATCH 29/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- Dockerfile | 1 + scripts/docker_start_all.sh | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 6504f15ae..2e1ebeaf1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,5 +27,6 @@ WORKDIR ${SERVER_WORKDIR} COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms +COPY --from=builder ${SERVER_WORKDIR}/_output/bin-tools/platforms /openim/openim-server/_output/bin-tools/platforms CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"] diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index f617c5057..5ddd68dab 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -30,6 +30,14 @@ need_to_start_server_shell=( ${SCRIPTS_ROOT}/start_cron.sh ) +component_check=start_component_check.sh +./$component_check +if [ $? -ne 0 ]; then + # Print error message and exit + echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + exit -1 +fi + #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started sleep 10 From 0957ff6eb8ef35479afe9dec7d52fbe15d23d33b Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 15:26:10 +0800 Subject: [PATCH 30/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 5ddd68dab..24a63fef9 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -31,7 +31,7 @@ need_to_start_server_shell=( ) component_check=start_component_check.sh -./$component_check +${SCRIPTS_ROOT}/$component_check if [ $? -ne 0 ]; then # Print error message and exit echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" From 8f14e3bec899ae5ea18ac3d41d5ca24768ccefc4 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 15:28:20 +0800 Subject: [PATCH 31/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 24a63fef9..303a1d0da 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -31,7 +31,7 @@ need_to_start_server_shell=( ) component_check=start_component_check.sh -${SCRIPTS_ROOT}/$component_check +$SCRIPTS_ROOT/$component_check if [ $? -ne 0 ]; then # Print error message and exit echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" From d46951e9490afdb1a53e3d064f3d5c88bc95a577 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 15:55:19 +0800 Subject: [PATCH 32/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 303a1d0da..c41ffbb4e 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -32,11 +32,11 @@ need_to_start_server_shell=( component_check=start_component_check.sh $SCRIPTS_ROOT/$component_check -if [ $? -ne 0 ]; then - # Print error message and exit - echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" - exit -1 -fi +#if [ $? -ne 0 ]; then +# # Print error message and exit +# echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" +# exit -1 +#fi #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started From 7a4fadf17c3c00367525ab0f49ed37904e0b51e4 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 15:57:28 +0800 Subject: [PATCH 33/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index c41ffbb4e..303a1d0da 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -32,11 +32,11 @@ need_to_start_server_shell=( component_check=start_component_check.sh $SCRIPTS_ROOT/$component_check -#if [ $? -ne 0 ]; then -# # Print error message and exit -# echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" -# exit -1 -#fi +if [ $? -ne 0 ]; then + # Print error message and exit + echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + exit -1 +fi #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started From 82db203d1bf74c444cbaee73f752929a084d6132 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 16:01:32 +0800 Subject: [PATCH 34/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 303a1d0da..c41ffbb4e 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -32,11 +32,11 @@ need_to_start_server_shell=( component_check=start_component_check.sh $SCRIPTS_ROOT/$component_check -if [ $? -ne 0 ]; then - # Print error message and exit - echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" - exit -1 -fi +#if [ $? -ne 0 ]; then +# # Print error message and exit +# echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" +# exit -1 +#fi #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started From 35bad3f76836afdff2fad71390c7992e7c73ff15 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 16:12:47 +0800 Subject: [PATCH 35/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index c41ffbb4e..303a1d0da 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -32,11 +32,11 @@ need_to_start_server_shell=( component_check=start_component_check.sh $SCRIPTS_ROOT/$component_check -#if [ $? -ne 0 ]; then -# # Print error message and exit -# echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" -# exit -1 -#fi +if [ $? -ne 0 ]; then + # Print error message and exit + echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + exit -1 +fi #fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started From 00fdc812f15fd8d5da30411c07770fac8ba94c3b Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 16:34:39 +0800 Subject: [PATCH 36/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- Dockerfile | 2 +- docker-compose.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2e1ebeaf1..7bc81b0bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ENV GOPROXY=$GOPROXY # Set up the working directory WORKDIR /openim/openim-server -COPY go.mod go.sum ./ +COPY go.mod go.sum go.work go.work.sum ./ RUN go mod download # Copy all files to the container diff --git a/docker-compose.yaml b/docker-compose.yaml index 2c0c98bd7..28fb1ceae 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -97,6 +97,7 @@ services: command: minio server /data --console-address ':9090' openim-server: + build: . image: ghcr.io/openimsdk/openim-server:latest container_name: openim-server volumes: From 59906e91793370aac3500f904f60687fbeed8be9 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 16:42:41 +0800 Subject: [PATCH 37/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 28fb1ceae..20202359a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -97,8 +97,8 @@ services: command: minio server /data --console-address ':9090' openim-server: - build: . image: ghcr.io/openimsdk/openim-server:latest + build: . container_name: openim-server volumes: - ./logs:/openim/openim-server/logs From b9431545991dffa18febe370528a5c320bb5e285 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 17:28:33 +0800 Subject: [PATCH 38/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- Dockerfile | 2 +- docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7bc81b0bb..321f8b03d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ENV GOPROXY=$GOPROXY WORKDIR /openim/openim-server COPY go.mod go.sum go.work go.work.sum ./ -RUN go mod download +#RUN go mod download # Copy all files to the container ADD . . diff --git a/docker-compose.yaml b/docker-compose.yaml index 20202359a..451886192 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -98,7 +98,7 @@ services: openim-server: image: ghcr.io/openimsdk/openim-server:latest - build: . +# build: . container_name: openim-server volumes: - ./logs:/openim/openim-server/logs From 7090383bd207b7f8f6dd138ac0f0e39d759b9a66 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 17:39:39 +0800 Subject: [PATCH 39/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 4e6329af5..bb68546c7 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -85,7 +85,7 @@ echo -e "" ./$component_check if [ $? -ne 0 ]; then # Print error message and exit - echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" + echo -e "${BOLD_PREFIX}${RED_PREFIX}Error executing ${component_check}. Exiting...${COLOR_SUFFIX}" exit -1 fi From fa2929deaa13fb627ca54e9dbc784a40adb40f19 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 17:42:30 +0800 Subject: [PATCH 40/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 451886192..2ed659be6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -97,8 +97,8 @@ services: command: minio server /data --console-address ':9090' openim-server: - image: ghcr.io/openimsdk/openim-server:latest -# build: . +# image: ghcr.io/openimsdk/openim-server:latest + build: . container_name: openim-server volumes: - ./logs:/openim/openim-server/logs From 970595f430ccec6322dc0471e87f768e7962a022 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 17:58:27 +0800 Subject: [PATCH 41/47] 816 Signed-off-by: hanzhixiao <709674996@qq.com> --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 2ed659be6..451886192 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -97,8 +97,8 @@ services: command: minio server /data --console-address ':9090' openim-server: -# image: ghcr.io/openimsdk/openim-server:latest - build: . + image: ghcr.io/openimsdk/openim-server:latest +# build: . container_name: openim-server volumes: - ./logs:/openim/openim-server/logs From f07e36c9d6a492b014879ec4bed12c0b6367d6b7 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 18:04:02 +0800 Subject: [PATCH 42/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 451886192..2ed659be6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -97,8 +97,8 @@ services: command: minio server /data --console-address ':9090' openim-server: - image: ghcr.io/openimsdk/openim-server:latest -# build: . +# image: ghcr.io/openimsdk/openim-server:latest + build: . container_name: openim-server volumes: - ./logs:/openim/openim-server/logs From 00cfd33353952a610ca6fbdfd5f0439cb62f0277 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 18:16:20 +0800 Subject: [PATCH 43/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- .github/workflows/scripts-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/scripts-test.yml b/.github/workflows/scripts-test.yml index 44b217c59..e837c8d53 100644 --- a/.github/workflows/scripts-test.yml +++ b/.github/workflows/scripts-test.yml @@ -61,8 +61,7 @@ jobs: - name: Build all services run: | - sudo chmod +x ./scripts/build_all_service.sh - sudo ./scripts/build_all_service.sh + sudo make build sudo cat logs/openIM.log 2>/dev/null shell: bash @@ -71,7 +70,6 @@ jobs: sudo chmod +x ./scripts/start_all.sh sudo ./scripts/start_all.sh sudo cat logs/openIM.log 2>/dev/null - continue-on-error: true shell: bash - name: Check all services From dec2f5e3a4e9a2eec5138e9292373cab3f6782fe Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 18:29:24 +0800 Subject: [PATCH 44/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- .github/workflows/scripts-test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts-test.yml b/.github/workflows/scripts-test.yml index e837c8d53..c3f2592f9 100644 --- a/.github/workflows/scripts-test.yml +++ b/.github/workflows/scripts-test.yml @@ -53,17 +53,15 @@ jobs: - name: Stop all services run: | - sudo chmod +x ./scripts/stop_all.sh sudo ./scripts/stop_all.sh - sudo cat logs/openIM.log 2>/dev/null shell: bash continue-on-error: true - name: Build all services run: | - sudo make build - sudo cat logs/openIM.log 2>/dev/null + make build shell: bash + continue-on-error: true - name: Start all services run: | From f40356ba390e94216c9b02dc6fd225016a1fd621 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 18:35:45 +0800 Subject: [PATCH 45/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/start_all.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/start_all.sh b/scripts/start_all.sh index bb68546c7..63cd6e1fd 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -82,6 +82,7 @@ echo -e "" chmod +x $component_check echo -e "=========> ${BACKGROUND_GREEN}Executing ${component_check}...${COLOR_SUFFIX}" echo -e "" +chmod +x ./$component_check ./$component_check if [ $? -ne 0 ]; then # Print error message and exit From f78f0a282029504218a89b87f335dbc532f3f3c5 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 18:40:27 +0800 Subject: [PATCH 46/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 1 + scripts/start_all.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 303a1d0da..9b10f48f3 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -31,6 +31,7 @@ need_to_start_server_shell=( ) component_check=start_component_check.sh +chmod +x ./$component_check $SCRIPTS_ROOT/$component_check if [ $? -ne 0 ]; then # Print error message and exit diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 63cd6e1fd..bb68546c7 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -82,7 +82,6 @@ echo -e "" chmod +x $component_check echo -e "=========> ${BACKGROUND_GREEN}Executing ${component_check}...${COLOR_SUFFIX}" echo -e "" -chmod +x ./$component_check ./$component_check if [ $? -ne 0 ]; then # Print error message and exit From 9bc82eedc38ebcf4ef630695faaa05dd82b60cd3 Mon Sep 17 00:00:00 2001 From: hanzhixiao <709674996@qq.com> Date: Wed, 9 Aug 2023 18:48:47 +0800 Subject: [PATCH 47/47] 815 Signed-off-by: hanzhixiao <709674996@qq.com> --- scripts/docker_start_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 9b10f48f3..24847e21e 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -31,7 +31,7 @@ need_to_start_server_shell=( ) component_check=start_component_check.sh -chmod +x ./$component_check +chmod +x $SCRIPTS_ROOT/$component_check $SCRIPTS_ROOT/$component_check if [ $? -ne 0 ]; then # Print error message and exit