From bd31f6b49cd1bb4310809743707944c04a269cd3 Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:03:54 +0800 Subject: [PATCH 1/3] Exit with code 1 when the check script fails (#2023) * 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 5282ab9f367b7b03da2f7eb1109ff2e89e988edf Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:11:07 +0800 Subject: [PATCH 2/3] Execute after the component check succeeds && minio.Enable is not configured to use MinIO (#2027) * 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 * 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 a5341346e9827885b6ac7567ded50a44859a7cda Mon Sep 17 00:00:00 2001 From: skiffer-git <72860476+skiffer-git@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:10:57 +0800 Subject: [PATCH 3/3] Log redirection causes incorrect program exit status. (#2031) * 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 * cicd: bump League Patch (#2025) * 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 * Log redirection causes incorrect program exit status. --------- Co-authored-by: OpenIM Bot <124379614+kubbot@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.6.md | 20 ++++++++++++++++++++ pkg/common/config/version | 2 +- scripts/install/openim-tools.sh | 4 +++- 3 files changed, 24 insertions(+), 2 deletions(-) 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 diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 003264221..f1a683ec3 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -101,7 +101,9 @@ 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