From a1f0eb2e3eb49551ddc6e1a757f6e8c6d74a45ee Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:56:22 +0800 Subject: [PATCH 01/10] Exit with code 1 when the check script fails (#2022) * Optimize script logs * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Optimizing Docker Log Output Detection * Exit with code 1 when the check script fails --- scripts/check-all.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 8e89af79d..d41023384 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -104,6 +104,7 @@ if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "check process failed.\n " echo "$result" + exit 1 else openim::log::success "All openim services are running normally! " fi From a93615d3e0645cf45931ab299d6b51691e6d1f30 Mon Sep 17 00:00:00 2001 From: OpenIM Bot <124379614+kubbot@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:28:48 +0800 Subject: [PATCH 02/10] cicd: bump League Patch (#2025) --- CHANGELOG/CHANGELOG-3.6.md | 20 ++++++++++++++++++++ pkg/common/config/version | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG/CHANGELOG-3.6.md diff --git a/CHANGELOG/CHANGELOG-3.6.md b/CHANGELOG/CHANGELOG-3.6.md new file mode 100644 index 000000000..214d58340 --- /dev/null +++ b/CHANGELOG/CHANGELOG-3.6.md @@ -0,0 +1,20 @@ +# Version logging for OpenIM + + + + + + +## [Unreleased] + + + +## v3.6.0 - 2024-03-07 +### Reverts +- update etcd to v3.5.2 ([#206](https://github.com/openimsdk/open-im-server/issues/206)) + +### Pull Requests +- Merge branch 'tuoyun' + + +[Unreleased]: https://github.com/openimsdk/open-im-server/compare/v3.6.0...HEAD diff --git a/pkg/common/config/version b/pkg/common/config/version index d5c0c9914..40c341bdc 100644 --- a/pkg/common/config/version +++ b/pkg/common/config/version @@ -1 +1 @@ -3.5.1 +3.6.0 From 42482e7eb45cf01a54fc5b4051503c8f31d33509 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:19:04 +0800 Subject: [PATCH 03/10] Execute after the component check succeeds && minio.Enable is not configured to use MinIO (#2026) * Exit with code 1 when the check script fails * Exit with code 1 when the check script fails * Exit with code 1 when the check script fails * Exit with code 1 when the check script fails * Handle the return value of pre-start * Handle the return value of pre-start * Handle the return value of pre-start * minio.Enable is not configured to use MinIO, therefore the image server is not checked * minio.Enable is not configured to use MinIO, therefore the image server is not checked * minio.Enable is not configured to use MinIO, therefore the image server is not checked * minio.Enable is not configured to use MinIO, therefore the image server is not checked --- scripts/install/openim-tools.sh | 25 +++++++++++++++++++------ scripts/start-all.sh | 12 ++++++++++-- tools/component/component.go | 24 +++++++++++++++++++++--- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 4eb722c6e..003264221 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -101,7 +101,16 @@ function openim::tools::start_service() { cmd="${cmd} --prometheus_port ${prometheus_port}" fi openim::log::status "Starting binary ${binary_name}..." - ${cmd} | tee -a "${LOG_FILE}" + ${cmd} >>"${LOG_FILE}" 2> >(tee -a "${LOG_FILE}" >&2) + local status=$? + + if [ $status -eq 0 ]; then + openim::log::info "Service ${binary_name} started successfully." + return 0 + else + openim::log::error "Failed to start service ${binary_name}." + return 1 + fi } function openim::tools::start() { @@ -115,11 +124,15 @@ function openim::tools::start() { function openim::tools::pre-start() { - openim::log::info "Preparing to start OpenIM Tools..." - for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do - openim::log::info "Starting tool ${tool}..." - openim::tools::start_service ${tool} ${OPNEIM_CONFIG} - done + openim::log::info "Preparing to start OpenIM Tools..." + for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do + openim::log::info "Starting tool ${tool}..." + if ! openim::tools::start_service ${tool} ${OPNEIM_CONFIG}; then + openim::log::error "Failed to start ${tool}, aborting..." + return 1 + fi + done + openim::log::info "All tools started successfully." } function openim::tools::post-start() { diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 419c16628..aac4b1837 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -83,10 +83,18 @@ fi # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::status "\n## Pre Starting OpenIM services" -${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start +openim::log::print_blue "\n## Pre Starting OpenIM services" + +if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then + openim::log::error "Pre Starting OpenIM services failed, aborting..." + exit 1 +fi + + +openim::log::print_blue "Pre Starting OpenIM services processed successfully" + result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then openim::log::error "View the error logs from this startup. ${LOG_FILE} \n" diff --git a/tools/component/component.go b/tools/component/component.go index 34d3dff6b..e3b5b1956 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -102,7 +102,14 @@ func main() { if !check.flag { err = check.function(check.config) if err != nil { - allSuccess = false + if errors.Is(err, errMinioNotEnabled) { + fmt.Println(err.Error()) + checks[index].flag = true + } + if errors.Is(err, errSignEndPoint) { + fmt.Fprintf(os.Stderr, err.Error()) + checks[index].flag = true + } component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, errs.Unwrap(err).Error())) if !strings.Contains(errs.Unwrap(err).Error(), "connection refused") && !strings.Contains(errs.Unwrap(err).Error(), "timeout waiting") { @@ -125,6 +132,11 @@ func main() { os.Exit(-1) } +var errMinioNotEnabled = errors.New("minio.Enable is not configured to use MinIO") + +var errSignEndPoint = errors.New("minio.signEndPoint contains 127.0.0.1, causing issues with image sending") +var errApiURL = errors.New("object.apiURL contains 127.0.0.1, causing issues with image sending") + // checkMongo checks the MongoDB connection without retries func checkMongo(config *config.GlobalConfig) error { mongoStu := &component.Mongo{ @@ -153,10 +165,16 @@ func checkRedis(config *config.GlobalConfig) error { // checkMinio checks the MinIO connection func checkMinio(config *config.GlobalConfig) error { - // Check if MinIO is enabled + if strings.Contains(config.Object.ApiURL, "127.0.0.1") { + return errs.Wrap(errApiURL, "config.Object.ApiURL: "+config.Object.ApiURL) + } if config.Object.Enable != "minio" { - return errs.Wrap(errors.New("minio.Enable is empty")) + return errs.Wrap(errMinioNotEnabled, "config.Object.Enable: "+config.Object.Enable) + } + if strings.Contains(config.Object.Minio.Endpoint, "127.0.0.1") { + return errs.Wrap(errSignEndPoint, "config.Object.Minio.Endpoint: "+config.Object.Minio.Endpoint) } + minio := &component.Minio{ ApiURL: config.Object.ApiURL, Endpoint: config.Object.Minio.Endpoint, From 16799648dc6d278b1706d4a0c78640097a7d862f Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:06:27 +0800 Subject: [PATCH 04/10] del log (#2030) --- scripts/install/openim-tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 003264221..04cd70adf 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -101,7 +101,7 @@ function openim::tools::start_service() { cmd="${cmd} --prometheus_port ${prometheus_port}" fi openim::log::status "Starting binary ${binary_name}..." - ${cmd} >>"${LOG_FILE}" 2> >(tee -a "${LOG_FILE}" >&2) + ${cmd} local status=$? if [ $status -eq 0 ]; then From eabe4d53da54d01154c872a6016b5087f3dc48e9 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 8 Mar 2024 14:56:44 +0800 Subject: [PATCH 05/10] delete --- scripts/lib/util.sh | 61 --------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index e9908ae66..f66971252 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -1808,68 +1808,7 @@ openim::util::stop_services_on_ports() { # Usage: # openim::util::stop_services_with_name nginx apache # The function returns a status of 1 if any service couldn't be stopped. -openim::util::stop_services_with_name() { - # An array to collect names of processes that couldn't be stopped. - local not_stopped=() - - # An array to collect information about processes that were stopped. - local stopped=() - - echo "Stopping services with names: $*" - # Iterate over each given service name. - for server_name in "$@"; do - # Use the `pgrep` command to find process IDs related to the given service name. - local pids=$(pgrep -f "$server_name") - - # If no process was found with the name, add it to the not_stopped list - if [[ -z $pids ]]; then - not_stopped+=("$server_name") - continue - fi - local stopped_this_time=false - for pid in $pids; do - # Exclude the PID of the current script - if [[ "$pid" == "$$" ]]; then - continue - fi - - # If there's a Process ID, it means the service with the name is running. - if [[ -n $pid ]]; then - # Try to stop the service by killing its process. - if kill -10 $pid 2>/dev/null; then - stopped_this_time=true - fi - fi - done - - if $stopped_this_time; then - stopped+=("$server_name") - else - not_stopped+=("$server_name") - fi - done - - # Print information about services whose processes couldn't be stopped. - if [[ ${#not_stopped[@]} -ne 0 ]]; then - echo "Services that couldn't be stopped:" - for name in "${not_stopped[@]}"; do - openim::log::status "Failed to stop the $name service." - done - fi - - # Print information about services whose processes were successfully stopped. - if [[ ${#stopped[@]} -ne 0 ]]; then - echo - echo "Stopped services:" - for name in "${stopped[@]}"; do - echo "Successfully stopped the $name service." - done - fi - - openim::log::success "All specified services were stopped." - echo "" -} # sleep 333333& # sleep 444444& # ps -ef | grep "sleep" From a3fff86ed854585c25b473139a16062856ba45a1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 8 Mar 2024 15:27:26 +0800 Subject: [PATCH 06/10] add context deadline exceeded --- tools/component/component.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index e3b5b1956..ef7efe487 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -111,10 +111,11 @@ func main() { checks[index].flag = true } component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, errs.Unwrap(err).Error())) - if !strings.Contains(errs.Unwrap(err).Error(), "connection refused") && - !strings.Contains(errs.Unwrap(err).Error(), "timeout waiting") { - component.ErrorPrint("Some components started failed!") - os.Exit(-1) + if strings.Contains(errs.Unwrap(err).Error(), "connection refused") || + strings.Contains(errs.Unwrap(err).Error(), "timeout") || + strings.Contains(errs.Unwrap(err).Error(), "context deadline exceeded") { + component.ErrorPrint("try check connection") + continue } } else { checks[index].flag = true From 210936411dc6c1b5b56890eea895322c66e90d00 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 8 Mar 2024 15:45:03 +0800 Subject: [PATCH 07/10] Error not handled --- tools/component/component.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index ef7efe487..cb2f306b0 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -259,13 +259,13 @@ func checkKafka(config *config.GlobalConfig) error { _, err = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{ KafkaVersion: sarama.V2_0_0_0, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false, - }, []string{config.Kafka.MsgToPush.Topic}, + }, []string{config.Kafka.MsgToMongo.Topic}, config.Kafka.Addr, config.Kafka.ConsumerGroupID.MsgToMongo, tlsConfig) if err != nil { return err } - kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{ + _, err = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{ KafkaVersion: sarama.V2_0_0_0, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false, }, []string{config.Kafka.MsgToPush.Topic}, config.Kafka.Addr, From 37947623e3e8fd61af0ea76f16b4cadd18bb8946 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 8 Mar 2024 15:56:54 +0800 Subject: [PATCH 08/10] Error not handled --- tools/component/component.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index cb2f306b0..33fec7c42 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -102,14 +102,17 @@ func main() { if !check.flag { err = check.function(check.config) if err != nil { - if errors.Is(err, errMinioNotEnabled) { - fmt.Println(err.Error()) - checks[index].flag = true - } - if errors.Is(err, errSignEndPoint) { - fmt.Fprintf(os.Stderr, err.Error()) - checks[index].flag = true + if check.name == "Minio" { + if errors.Is(err, errMinioNotEnabled) { + fmt.Println(err.Error()) + checks[index].flag = true + } + if errors.Is(err, errSignEndPoint) { + fmt.Fprintf(os.Stderr, err.Error()) + checks[index].flag = true + } } + component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, errs.Unwrap(err).Error())) if strings.Contains(errs.Unwrap(err).Error(), "connection refused") || strings.Contains(errs.Unwrap(err).Error(), "timeout") || From 54f13e74ff0b1bb413495946f36075633b03c737 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 8 Mar 2024 15:58:03 +0800 Subject: [PATCH 09/10] Error not handled --- tools/component/component.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/component/component.go b/tools/component/component.go index 33fec7c42..f5f908fa3 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -117,7 +117,7 @@ func main() { if strings.Contains(errs.Unwrap(err).Error(), "connection refused") || strings.Contains(errs.Unwrap(err).Error(), "timeout") || strings.Contains(errs.Unwrap(err).Error(), "context deadline exceeded") { - component.ErrorPrint("try check connection") + component.ErrorPrint(fmt.Sprintf("try check connection %s", check.name)) continue } } else { From caed25252d161108be56a0ea01acef235d3f70e6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 8 Mar 2024 16:03:59 +0800 Subject: [PATCH 10/10] Error not handled --- tools/component/component.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/component/component.go b/tools/component/component.go index f5f908fa3..c7c135549 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -104,11 +104,11 @@ func main() { if err != nil { if check.name == "Minio" { if errors.Is(err, errMinioNotEnabled) { - fmt.Println(err.Error()) + fmt.Println(err.Error(), " check ", check.name) checks[index].flag = true } if errors.Is(err, errSignEndPoint) { - fmt.Fprintf(os.Stderr, err.Error()) + fmt.Fprintf(os.Stderr, err.Error(), " check ", check.name) checks[index].flag = true } } @@ -118,7 +118,8 @@ func main() { strings.Contains(errs.Unwrap(err).Error(), "timeout") || strings.Contains(errs.Unwrap(err).Error(), "context deadline exceeded") { component.ErrorPrint(fmt.Sprintf("try check connection %s", check.name)) - continue + allSuccess = false + break } } else { checks[index].flag = true