From 7077083aca421c2e1c199c1607733a6c6fa34f32 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 15:54:18 +0800 Subject: [PATCH 01/77] fix: del the error world --- install.sh | 2 +- scripts/advertise.sh | 2 +- scripts/build-all-service.sh | 4 ++-- scripts/check-all.sh | 4 ++-- scripts/cherry-pick.sh | 4 ++-- scripts/common.sh | 6 +++--- scripts/docker-start-all.sh | 4 ++-- scripts/gen-swagger-docs.sh | 4 ++-- scripts/init-config.sh | 4 ++-- scripts/init-env.sh | 2 +- scripts/install-im-server.sh | 4 ++-- scripts/install/common.sh | 6 +++--- scripts/install/dependency.sh | 6 +++--- scripts/install/install.sh | 2 +- scripts/install/openim-api.sh | 8 ++++---- scripts/install/openim-crontask.sh | 2 +- scripts/install/openim-man.sh | 2 +- scripts/install/openim-msggateway.sh | 8 ++++---- scripts/install/openim-msgtransfer.sh | 8 ++++---- scripts/install/openim-push.sh | 8 ++++---- scripts/install/openim-rpc.sh | 8 ++++---- scripts/install/openim-tools.sh | 6 +++--- scripts/lib/init.sh | 6 +++--- scripts/lib/logging.sh | 2 +- scripts/lib/util.sh | 4 ++-- scripts/list-feature-tests.sh | 4 ++-- scripts/release.sh | 4 ++-- scripts/run-in-gopath.sh | 4 ++-- scripts/start-all.sh | 4 ++-- scripts/stop-all.sh | 4 ++-- scripts/update-generated-docs.sh | 4 ++-- scripts/update-yamlfmt.sh | 4 ++-- scripts/verify-pkg-names.sh | 4 ++-- scripts/verify-shellcheck.sh | 4 ++-- scripts/verify-spelling.sh | 4 ++-- scripts/verify-typecheck.sh | 4 ++-- scripts/verify-yamlfmt.sh | 4 ++-- 37 files changed, 82 insertions(+), 82 deletions(-) diff --git a/install.sh b/install.sh index 7ff0f87393..4b8e74c55e 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ # set -e -set -o pipefail + ############################## OpenIM Github ############################## # ... rest of the script ... diff --git a/scripts/advertise.sh b/scripts/advertise.sh index 3effc4f2bd..958b4e3ae6 100755 --- a/scripts/advertise.sh +++ b/scripts/advertise.sh @@ -14,7 +14,7 @@ # limitations under the License. set -e -set -o pipefail + . $(dirname ${BASH_SOURCE})/lib/init.sh diff --git a/scripts/build-all-service.sh b/scripts/build-all-service.sh index b5578fca63..f5bd491264 100755 --- a/scripts/build-all-service.sh +++ b/scripts/build-all-service.sh @@ -22,9 +22,9 @@ # Usage: `scripts/build-all-service.sh`. # Example: `scripts/build-go.sh WHAT=cmd/kubelet`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 062605ae11..c37b3446de 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -19,9 +19,9 @@ # Encapsulated as: `make check`. # READ: https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" diff --git a/scripts/cherry-pick.sh b/scripts/cherry-pick.sh index 8a1f8dd794..a072f1ecf8 100755 --- a/scripts/cherry-pick.sh +++ b/scripts/cherry-pick.sh @@ -21,9 +21,9 @@ # checks them out to a branch named: # automated-cherry-pick-of--- -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/common.sh b/scripts/common.sh index d67389d56a..702f555885 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -18,9 +18,9 @@ # shellcheck disable=SC2034 # Variables sourced in other scripts. # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + # Unset CDPATH, having it set messes up with script import paths unset CDPATH diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh index 1626555536..e3babbeb41 100755 --- a/scripts/docker-start-all.sh +++ b/scripts/docker-start-all.sh @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit + set -o nounset -set -o pipefail + #fixme This scripts is the total startup scripts #fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array diff --git a/scripts/gen-swagger-docs.sh b/scripts/gen-swagger-docs.sh index 68410e79c5..311ae8e15e 100755 --- a/scripts/gen-swagger-docs.sh +++ b/scripts/gen-swagger-docs.sh @@ -15,9 +15,9 @@ # Script to generate docs from the latest swagger spec. -set -o errexit + set -o nounset -set -o pipefail + # The root of the build/dist directory OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 82eefbb54d..34b4039235 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -15,9 +15,9 @@ # This script automatically initializes various configuration files and can generate example files. -set -o errexit + set -o nounset -set -o pipefail + # Root directory of the OpenIM project OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/init-env.sh b/scripts/init-env.sh index 75b871b088..495a8fcf42 100755 --- a/scripts/init-env.sh +++ b/scripts/init-env.sh @@ -17,7 +17,7 @@ #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. set -o nounset -set -o pipefail + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P) source "${OPENIM_ROOT}/scripts/install/common.sh" diff --git a/scripts/install-im-server.sh b/scripts/install-im-server.sh index c1224e30c8..426779be05 100755 --- a/scripts/install-im-server.sh +++ b/scripts/install-im-server.sh @@ -27,9 +27,9 @@ # Usage: # SERVER_IMAGE_VERSION=latest IMAGE_REGISTRY=myregistry ./this_script.sh -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/install/common.sh b/scripts/install/common.sh index f6ee5d3ad2..add1eebf89 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -15,9 +15,9 @@ # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + # Sourced flag COMMON_SOURCED=true diff --git a/scripts/install/dependency.sh b/scripts/install/dependency.sh index e7c7eb426f..bad1cb6f92 100755 --- a/scripts/install/dependency.sh +++ b/scripts/install/dependency.sh @@ -15,9 +15,9 @@ # This script will install the dependencies required for openim -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh diff --git a/scripts/install/install.sh b/scripts/install/install.sh index d5ec5b7f77..bb09675bfd 100755 --- a/scripts/install/install.sh +++ b/scripts/install/install.sh @@ -109,7 +109,7 @@ function openim::uninstall::uninstall_openim() { openim::common::sudo "systemctl stop openim.target" openim::common::sudo "systemctl disable openim.target" openim::common::sudo "rm -f /etc/systemd/system/openim.target" - set -o errexit + openim::log::success "openim uninstall success" } diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index be2a2d33b3..6977b519d5 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -138,7 +138,7 @@ function openim::api::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh index 395b27cd1b..97bdf86307 100755 --- a/scripts/install/openim-crontask.sh +++ b/scripts/install/openim-crontask.sh @@ -107,7 +107,7 @@ function openim::crontask::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-man.sh b/scripts/install/openim-man.sh index fac5cebea4..642588a287 100755 --- a/scripts/install/openim-man.sh +++ b/scripts/install/openim-man.sh @@ -76,7 +76,7 @@ function openim::man::uninstall() { # Turn off exit-on-error temporarily to handle non-existing files gracefully set +o errexit openim::common::sudo "rm -f /usr/share/man/man1/openim-*" - set -o errexit + openim::log::info "Uninstalled openim man pages successfully" } diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index a2316c784d..903f2d32e0 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -14,9 +14,9 @@ # limitations under the License. # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -117,7 +117,7 @@ function openim::msggateway::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 783e067297..bd3e51b0e7 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -16,9 +16,9 @@ # ./scripts/install/openim-msgtransfer.sh openim::msgtransfer::start # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -138,7 +138,7 @@ function openim::msgtransfer::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 95da16c8a9..6df1d7b09e 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -40,9 +40,9 @@ # # Note: Ensure that the appropriate permissions and environmental variables are set prior to script execution. # -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -125,7 +125,7 @@ function openim::push::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index f8feaaa572..e569cf114c 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -38,9 +38,9 @@ # Note: Before executing this script, ensure that the necessary permissions are granted and relevant environmental variables are set. # -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -220,7 +220,7 @@ function openim::rpc::uninstall() { openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${service}.yaml" openim::common::sudo "rm -f ${SYSTEM_FILE_PATHS[$service]}" done - set -o errexit + openim::log::info "uninstall openim-rpc successfully" } diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index ac60a5f45e..f41ed01b94 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -38,9 +38,9 @@ # Example: ./openim-tools.sh openim::tools::install # -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh diff --git a/scripts/lib/init.sh b/scripts/lib/init.sh index be8e9f8aa5..4cd6d9fb88 100755 --- a/scripts/lib/init.sh +++ b/scripts/lib/init.sh @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit -set +o nounset -set -o pipefail + + + # Short-circuit if init.sh has already been sourced [[ $(type -t openim::init::loaded) == function ]] && return 0 diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 8f2bb33cf7..0c34be831a 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -75,7 +75,7 @@ openim::log::errexit() { openim::log::install_errexit() { # trap ERR to provide an error handler whenever a command exits nonzero this - # is a more verbose version of set -o errexit + # is a more verbose version of trap 'openim::log::errexit' ERR # setting errtrace allows our ERR trap handler to be propagated to functions, diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 1bdb7f6404..51fc8af673 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -373,7 +373,7 @@ openim::util::check_ports() { # set +o errexit # Sample call for testing: # openim::util::check_ports 10002 1004 12345 13306 -# set -o errexit +# # The `openim::util::check_process_names` function analyzes the state of processes based on given names. # It accepts multiple process names as arguments and prints: @@ -1607,7 +1607,7 @@ openim::util::check_ports() { # set +o errexit # Sample call for testing: # openim::util::check_ports 10002 1004 12345 13306 -# set -o errexit +# # The `openim::util::check_process_names` function analyzes the state of processes based on given names. # It accepts multiple process names as arguments and prints: diff --git a/scripts/list-feature-tests.sh b/scripts/list-feature-tests.sh index 438474baea..7ed19e25dd 100755 --- a/scripts/list-feature-tests.sh +++ b/scripts/list-feature-tests.sh @@ -18,9 +18,9 @@ # # Usage: `scripts/list-feature-tests.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. grep "\[Feature:\w+\]" "${OPENIM_ROOT}"/test/e2e/**/*.go -Eoh | LC_ALL=C sort -u \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh index a34d5ee229..ed981a0ed8 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -47,9 +47,9 @@ # images and other build artifacts. # Build a OpenIM release. This script supports various flags for flexible execution control. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/common.sh" source "${OPENIM_ROOT}/scripts/lib/release.sh" diff --git a/scripts/run-in-gopath.sh b/scripts/run-in-gopath.sh index 9bb8ec8821..cbad11d396 100755 --- a/scripts/run-in-gopath.sh +++ b/scripts/run-in-gopath.sh @@ -20,9 +20,9 @@ # the project. # Usage: `scripts/run-in-gopath.sh `. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/start-all.sh b/scripts/start-all.sh index ca03f0c3ce..2c65812087 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -17,7 +17,7 @@ #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" @@ -30,7 +30,7 @@ if [[ $? -ne 0 ]]; then openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries." "${OPENIM_ROOT}"/scripts/build-all-service.sh fi -set -o errexit + "${OPENIM_ROOT}"/scripts/init-config.sh --skip diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 2acb9cdc52..0754185098 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -18,9 +18,9 @@ # Usage: `scripts/stop.sh`. # Encapsulated as: `make stop`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/update-generated-docs.sh b/scripts/update-generated-docs.sh index c37c4a1f9e..84b5c0f8d5 100755 --- a/scripts/update-generated-docs.sh +++ b/scripts/update-generated-docs.sh @@ -18,9 +18,9 @@ # immediately before exporting docs. We do not want to check these documents in # by default. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/update-yamlfmt.sh b/scripts/update-yamlfmt.sh index 90ec8aa627..e9cfd63e2a 100755 --- a/scripts/update-yamlfmt.sh +++ b/scripts/update-yamlfmt.sh @@ -14,9 +14,9 @@ # limitations under the License. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-pkg-names.sh b/scripts/verify-pkg-names.sh index 1459992e9d..1357c6cb7a 100755 --- a/scripts/verify-pkg-names.sh +++ b/scripts/verify-pkg-names.sh @@ -17,9 +17,9 @@ # This script verifies whether codes follow golang convention. # Usage: `scripts/verify-pkg-names.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-shellcheck.sh b/scripts/verify-shellcheck.sh index 8a5ad7321e..0b8687edbb 100755 --- a/scripts/verify-shellcheck.sh +++ b/scripts/verify-shellcheck.sh @@ -17,9 +17,9 @@ # This script lints each shell script by `shellcheck`. # Usage: `scripts/verify-shellcheck.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-spelling.sh b/scripts/verify-spelling.sh index 2c02dccf7d..d2830f591e 100755 --- a/scripts/verify-spelling.sh +++ b/scripts/verify-spelling.sh @@ -17,9 +17,9 @@ # working directory by client9/misspell package. # Usage: `scripts/verify-spelling.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. export OPENIM_ROOT diff --git a/scripts/verify-typecheck.sh b/scripts/verify-typecheck.sh index 62fca40491..529c353972 100755 --- a/scripts/verify-typecheck.sh +++ b/scripts/verify-typecheck.sh @@ -16,9 +16,9 @@ # This script does a fast type check of script srnetes code for all platforms. # Usage: `scripts/verify-typecheck.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-yamlfmt.sh b/scripts/verify-yamlfmt.sh index 3d0a0180dd..636a9c8e43 100755 --- a/scripts/verify-yamlfmt.sh +++ b/scripts/verify-yamlfmt.sh @@ -19,9 +19,9 @@ # # Usage: `scripts/verify-yamlfmt.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" From 5f71f27c639d337f14a1635ededf537486d76d1f Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 18:00:26 +0800 Subject: [PATCH 02/77] fix: refactoring scripts --- scripts/check-all.sh | 22 ++--- scripts/install/common.sh | 12 +++ scripts/install/openim-api.sh | 27 +++-- scripts/install/openim-crontask.sh | 8 +- scripts/install/openim-msggateway.sh | 9 +- scripts/install/openim-msgtransfer.sh | 37 ++++++- scripts/install/openim-push.sh | 8 +- scripts/install/openim-rpc.sh | 25 +++-- scripts/install/openim-tools.sh | 2 - scripts/lib/golang.sh | 18 ++++ scripts/lib/util.sh | 137 ++++++++++++++++++++++---- scripts/start-all.sh | 27 +++-- scripts/stop-all.sh | 18 +++- 13 files changed, 279 insertions(+), 71 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index c37b3446de..f7e29376bb 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -49,13 +49,6 @@ print_services_and_ports() { echo "+-------------------------+----------+" } -handle_error() { - echo "An error occurred. Printing ${STDERR_LOG_FILE} contents:" - cat "${STDERR_LOG_FILE}" - exit 1 -} - -trap handle_error ERR # Assuming OPENIM_SERVER_NAME_TARGETS and OPENIM_SERVER_PORT_TARGETS are defined # Similarly for OPENIM_DEPENDENCY_TARGETS and OPENIM_DEPENDENCY_PORT_TARGETS @@ -71,7 +64,6 @@ echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}" openim::log::info "\n## Check all dependent service ports" echo "++ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}" -set +e # Later, after discarding Docker, the Docker keyword is unreliable, and Kubepods is used if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then @@ -92,15 +84,17 @@ openim::log::info "\n## Check OpenIM service name" . $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check openim::log::info "\n## Check all OpenIM service ports" -echo "+++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}" -openim::util::check_ports ${OPENIM_SERVER_PORT_LISTARIES[@]} +echo "+++ The process being checked:" +for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do + echo "$item" +done +result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error_exit "The service does not start properly, please check the port, query variable definition!" + openim::log::error "check process failed.\n $result" + return 1 else echo "++++ Check all openim service ports successfully !" + return 0 fi -set -e - -trap - ERR \ No newline at end of file diff --git a/scripts/install/common.sh b/scripts/install/common.sh index add1eebf89..32498d94c7 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -99,6 +99,18 @@ IFS=" " read -ra OPENIM_SERVER_PORT_TARGETS <<< "$(openim::common::service_port) readonly OPENIM_SERVER_PORT_TARGETS readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}") +OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=() +for target in openim::golang::server_targets_no_transfer; do + OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") +done +readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER + +OPENIM_ALL_SERVICE_LIBRARIES=() +for target in openim::golang::server_targets; do + OPENIM_ALL_SERVICE_LIBRARIES+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") +done +readonly OPENIM_ALL_SERVICE_LIBRARIES + openim::common::dependency_name() { local targets=( redis diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index 6977b519d5..933fef2ce8 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -47,24 +47,37 @@ function openim::api::start() { openim::log::info "Starting ${SERVER_NAME} ..." + readonly OPENIM_API_SERVER_LIBRARIES="${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME}" + result=$(openim::util::stop_services_with_name ${OPENIM_API_SERVER_LIBRARIES}) + if [[ $? -ne 0 ]]; then + openim::log::error "stop ${SERVER_NAME} failed" + return 1 + fi + printf "+------------------------+--------------+\n" printf "| Service Name | Port |\n" printf "+------------------------+--------------+\n" - + + local length=${#OPENIM_API_SERVICE_LISTARIES[@]} - for ((i=0; i> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & - openim::util::check_process_names ${SERVER_NAME} + return 0 } diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index 903f2d32e0..79bdee2229 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -32,7 +32,11 @@ function openim::msggateway::start() { openim::log::info "Start OpenIM Msggateway, binary root: ${SERVER_NAME}" openim::log::status "Start OpenIM Msggateway, path: ${OPENIM_MSGGATEWAY_BINARY}" - openim::util::stop_services_with_name ${OPENIM_MSGGATEWAY_BINARY} + result=$(openim::util::stop_services_with_name ${OPENIM_MSGGATEWAY_BINARY}) + if [[ $? -ne 0 ]]; then + openim::log::error "stop ${SERVER_NAME} failed" + return 1 + fi # OpenIM message gateway service port OPENIM_MESSAGE_GATEWAY_PORTS=$(openim::util::list-to-string ${OPENIM_MESSAGE_GATEWAY_PORT} ) @@ -66,8 +70,7 @@ function openim::msggateway::start() { nohup ${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & done - - openim::util::check_process_names ${SERVER_NAME} + return 0 } ###################################### Linux Systemd ###################################### diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index bd3e51b0e7..ca4d1086e2 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -34,7 +34,11 @@ function openim::msgtransfer::start() { openim::log::info "Start OpenIM Msggateway, binary root: ${SERVER_NAME}" openim::log::status "Start OpenIM Msggateway, path: ${OPENIM_MSGTRANSFER_BINARY}" - openim::util::stop_services_with_name ${OPENIM_MSGTRANSFER_BINARY} + result=$(openim::util::stop_services_with_name ${OPENIM_MSGTRANSFER_BINARY}) + if [[ $? -ne 0 ]]; then + openim::log::error "stop ${SERVER_NAME} failed" + return 1 + fi # Message Transfer Prometheus port list MSG_TRANSFER_PROM_PORTS=(openim::util::list-to-string ${MSG_TRANSFER_PROM_PORT} ) @@ -63,8 +67,8 @@ function openim::msgtransfer::start() { fi nohup ${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & done - - openim::util::check_process_names "${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME}" + return 0 + } function openim::msgtransfer::check() { @@ -88,6 +92,33 @@ function openim::msgtransfer::check() { fi } +function openim::msgtransfer::check_for_stop() { + PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") || PIDS="0" + if [ "$PIDS" = "0" ]; then + return 0 + fi + + NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) + + if [ "$NUM_PROCESSES" -gt 0 ]; then + openim::log::error "Found $NUM_PROCESSES processes for $OPENIM_OUTPUT_HOSTBIN/openim-msgtransfer" + for PID in $PIDS; do + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + echo -e "\033[31m$(ps -p $PID -o pid,cmd)\033[0m" + elif [[ "$OSTYPE" == "darwin"* ]]; then + echo -e "\033[31m$(ps -p $PID -o pid,comm)\033[0m" + else + openim::log::error "Unsupported OS type: $OSTYPE" + fi + done + openim::log::error "Processes have not been stopped properly." + else + openim::log::success "All openim-msgtransfer processes have been stopped properly." + fi + return 0 +} + + ###################################### Linux Systemd ###################################### SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 6df1d7b09e..23f4d72e3b 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -62,7 +62,11 @@ function openim::push::start() { OPENIM_PUSH_PORTS_ARRAY=$(openim::util::list-to-string ${OPENIM_PUSH_PORT} ) PUSH_PROM_PORTS_ARRAY=$(openim::util::list-to-string ${PUSH_PROM_PORT} ) - openim::util::stop_services_with_name ${SERVER_NAME} + result=$(openim::util::stop_services_with_name ${SERVER_NAME}) + if [[ $? -ne 0 ]]; then + openim::log::error "stop ${SERVER_NAME} failed" + return 1 + fi openim::log::status "push port list: ${OPENIM_PUSH_PORTS_ARRAY[@]}" openim::log::status "prometheus port list: ${PUSH_PROM_PORTS_ARRAY[@]}" @@ -75,8 +79,8 @@ function openim::push::start() { openim::log::info "start push process, port: ${OPENIM_PUSH_PORTS_ARRAY[$i]}, prometheus port: ${PUSH_PROM_PORTS_ARRAY[$i]}" nohup ${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & done + return 0 - openim::util::check_process_names ${SERVER_NAME} } ###################################### Linux Systemd ###################################### diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index e569cf114c..95cce7ffa9 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -121,11 +121,13 @@ function openim::rpc::start() { printf "+------------------------+-------+-----------------+\n" done + result=$(openim::util::stop_services_with_name ${OPENIM_API_SERVER_LIBRARIES}) + if [[ $? -ne 0 ]]; then + openim::log::error "stop ${SERVER_NAME} failed" + fi + # start all rpc services for ((i = 0; i < ${#OPENIM_RPC_SERVICE_LISTARIES[*]}; i++)); do - # openim::util::stop_services_with_name ${OPENIM_RPC_SERVICE_LISTARIES - openim::util::stop_services_on_ports ${OPENIM_RPC_PORT_LISTARIES[$i]} - openim::util::stop_services_on_ports ${OPENIM_RPC_PROM_PORT_LISTARIES[$i]} openim::log::info "OpenIM ${OPENIM_RPC_SERVICE_LISTARIES[$i]} config path: ${OPENIM_RPC_CONFIG}" @@ -138,15 +140,25 @@ function openim::rpc::start() { for ((j = 0; j < ${#OPENIM_RPC_SERVICE_PORTS_ARRAY[@]}; j++)); do openim::log::info "Starting ${OPENIM_RPC_SERVICE_LISTARIES[$i]} service, port: ${OPENIM_RPC_SERVICE_PORTS[j]}, prometheus port: ${OPENIM_RPC_PROM_PORTS[j]}, binary root: ${OPENIM_OUTPUT_HOSTBIN}/${OPENIM_RPC_SERVICE_LISTARIES[$i]}" - openim::rpc::start_service "${OPENIM_RPC_SERVICE_LISTARIES[$i]}" "${OPENIM_RPC_SERVICE_PORTS[j]}" "${OPENIM_RPC_PROM_PORTS[j]}" + result=$(openim::rpc::start_service "${OPENIM_RPC_SERVICE_LISTARIES[$i]}" "${OPENIM_RPC_SERVICE_PORTS[j]}" "${OPENIM_RPC_PROM_PORTS[j]}") + if [[ $? -ne 0 ]]; then + openim::log::error "stop ${SERVER_NAME} failed" + else + openim::log::info "$result" + fi done done sleep 5 - openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]} + result=$(openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]}) + if [[ $? -ne 0 ]]; then + openim::log::error "check ${SERVER_NAME} failed" + else + openim::log::info "$result" + fi # openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]} - + return 0 } function openim::rpc::start_service() { @@ -161,6 +173,7 @@ function openim::rpc::start_service() { cmd="${cmd} --prometheus_port ${prometheus_port}" fi nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & + return 0 } ###################################### Linux Systemd ###################################### diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index f41ed01b94..72005ed8e4 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -122,7 +122,6 @@ function openim::tools::pre-start() { for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do openim::log::info "Starting ${tool}..." openim::tools::start_service ${tool} ${OPNEIM_CONFIG} - sleep 0.2 done } @@ -131,7 +130,6 @@ function openim::tools::post-start() { for tool in "${OPENIM_TOOLS_POST_START_NAME_LISTARIES[@]}"; do openim::log::info "Starting ${tool}..." openim::tools::start_service ${tool} - sleep 0.2 done } diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index af04771d5d..22bef6bc1b 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -84,6 +84,24 @@ openim::golang::server_targets() { echo "${targets[@]}" } +openim::golang::server_targets_no_transfer() { + local targets=( + openim-api + openim-cmdutils + openim-crontask + openim-msggateway + openim-push + openim-rpc-auth + openim-rpc-conversation + openim-rpc-friend + openim-rpc-group + openim-rpc-msg + openim-rpc-third + openim-rpc-user + ) + echo "${targets[@]}" +} + IFS=" " read -ra OPENIM_SERVER_TARGETS <<< "$(openim::golang::server_targets)" readonly OPENIM_SERVER_TARGETS readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}") diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 51fc8af673..38f2a29566 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -457,6 +457,81 @@ openim::util::check_process_names() { fi } +openim::util::check_process_names_for_stop() { + # Function to get the port of a process + get_port() { + local pid=$1 + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Linux + ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2 + elif [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + lsof -nP -iTCP -sTCP:LISTEN -a -p $pid | awk 'NR>1 {print $9}' | sed 's/.*://' + else + echo "Unsupported OS" + return 1 + fi + } + + # Arrays to collect details of processes + local not_started=() + local started=() + + openim::log::info "Checking processes: $*" + # Iterate over each given process name + for process_name in "$@"; do + # Use `pgrep` to find process IDs related to the given process name + local pids=($(pgrep -f $process_name)) + + # Check if any process IDs were found + if [[ ${#pids[@]} -eq 0 ]]; then + not_started+=($process_name) + else + # If there are PIDs, loop through each one + for pid in "${pids[@]}"; do + local command=$(ps -p $pid -o cmd=) + local start_time=$(ps -p $pid -o lstart=) + local port=$(get_port $pid) + + # Check if port information was found for the PID + if [[ -z $port ]]; then + port="N/A" + fi + + started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time") + done + fi + done + + # Print information + if [[ ${#not_started[@]} -ne 0 ]]; then + openim::log::info "Not started processes:" + for process_name in "${not_started[@]}"; do + openim::log::error "Process $process_name is not started." + done + fi + + if [[ ${#started[@]} -ne 0 ]]; then + echo + openim::log::info "Started processes:" + for info in "${started[@]}"; do + openim::log::info "$info" + done + fi + + # Return status + if [[ ${#not_started[@]} -ne 0 ]]; then + openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' + return 1 + else + echo "" + openim::log::success "All processes are running." + return 0 + fi +} + # openim::util::check_process_names docker-pr # The `openim::util::stop_services_on_ports` function stops services running on specified ports. @@ -573,26 +648,8 @@ openim::util::stop_services_with_name() { not_stopped+=("$server_name") fi done + return 0 - # Print information about services whose processes couldn't be stopped. - if [[ ${#not_stopped[@]} -ne 0 ]]; then - openim::log::info "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 - openim::log::info "Stopped services:" - for name in "${stopped[@]}"; do - openim::log::info "Successfully stopped the $name service." - done - fi - - openim::log::success "All specified services were stopped." - echo "" } # sleep 333333& # sleep 444444& @@ -2822,6 +2879,46 @@ function openim::util::gen_os_arch() { fi } + + +function openim::util::check_process_names_for_stop() { + local all_stopped=true + + for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do + PIDS=$(pgrep -f "${service}") || PIDS="0" + if [ "$PIDS" = "0" ]; then + continue + fi + + all_stopped=false + NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) + + if [ "$NUM_PROCESSES" -gt 0 ]; then + openim::log::error "Found $NUM_PROCESSES processes for ${service}" + for PID in $PIDS; do + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + echo -e "\033[31m$(ps -p $PID -o pid,cmd)\033[0m" + elif [[ "$OSTYPE" == "darwin"* ]]; then + echo -e "\033[31m$(ps -p $PID -o pid,comm)\033[0m" + else + openim::log::error "Unsupported OS type: $OSTYPE" + fi + done + openim::log::error "Processes for ${service} have not been stopped properly." + fi + done + + if [ "$all_stopped" = true ]; then + openim::log::success "All processes have been stopped properly." + return 0 + fi + + return 1 +} + + + + if [[ "$*" =~ openim::util:: ]];then eval $* -fi \ No newline at end of file +fi diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 2c65812087..39c5d1bf2a 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -54,19 +54,18 @@ function execute_scripts() { openim::log::status "Starting script: ${script_path##*/}" # Log the script name. # Execute the script with the constructed argument. - "$script_path" "$arg" - - # Check if the script executed successfully. - if [[ $? -eq 0 ]]; then - openim::log::info "${script_path##*/} executed successfully." - else - openim::log::errexit "Error executing ${script_path##*/}." + result=$("$script_path" "$arg") + if [[ $? -ne 0 ]]; then + openim::log::error "Start script: ${script_path##*/} failed" + openim::log::error "$result" + return 1 fi + else openim::log::errexit "Script ${script_path##*/} is missing or not executable." + return 1 fi done - sleep 0.5 } @@ -79,6 +78,18 @@ ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start openim::log::info "\n## Starting OpenIM services" execute_scripts +sleep 2 + +openim::log::info "\n## Check OpenIM service name" +. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check + +echo "+++ The process being checked:" +for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do + echo "$item" +done + +openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} + openim::log::info "\n## Post Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 0754185098..9b2baa23d1 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -28,12 +28,20 @@ source "${OPENIM_ROOT}/scripts/install/common.sh" openim::log::info "\n# Begin to stop all openim service" -echo "++ Ready to stop port: ${OPENIM_SERVER_PORT_LISTARIES[@]}" - -openim::util::stop_services_on_ports ${OPENIM_SERVER_PORT_LISTARIES[@]} - echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" +# todo OPENIM_ALL_SERVICE_LIBRARIES + + + + + +result=$(openim::util::check_process_names_for_stop) +if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "stop process failed.\n$(result)" + return 1 +fi -openim::log::success "✨ All processes to be killed" \ No newline at end of file +openim::log::success "✨ All processes to be stopped" \ No newline at end of file From 84e916e35218d132d89a59ba0b04d8cff62a9faa Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 18:05:39 +0800 Subject: [PATCH 03/77] fix: del nounset --- scripts/build-all-service.sh | 2 +- scripts/check-all.sh | 2 +- scripts/cherry-pick.sh | 2 +- scripts/docker-start-all.sh | 2 +- scripts/gen-swagger-docs.sh | 2 +- scripts/init-config.sh | 2 +- scripts/init-env.sh | 2 +- scripts/install-im-server.sh | 2 +- scripts/list-feature-tests.sh | 2 +- scripts/release.sh | 2 +- scripts/run-in-gopath.sh | 2 +- scripts/start-all.sh | 2 +- scripts/stop-all.sh | 2 +- scripts/update-generated-docs.sh | 2 +- scripts/update-yamlfmt.sh | 2 +- scripts/verify-pkg-names.sh | 2 +- scripts/verify-shellcheck.sh | 2 +- scripts/verify-spelling.sh | 2 +- scripts/verify-typecheck.sh | 2 +- scripts/verify-yamlfmt.sh | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/build-all-service.sh b/scripts/build-all-service.sh index f5bd491264..6335b0e08d 100755 --- a/scripts/build-all-service.sh +++ b/scripts/build-all-service.sh @@ -23,7 +23,7 @@ # Example: `scripts/build-go.sh WHAT=cmd/kubelet`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/check-all.sh b/scripts/check-all.sh index f7e29376bb..17fb5fb7c8 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -20,7 +20,7 @@ # READ: https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/cherry-pick.sh b/scripts/cherry-pick.sh index a072f1ecf8..f8d7912f81 100755 --- a/scripts/cherry-pick.sh +++ b/scripts/cherry-pick.sh @@ -22,7 +22,7 @@ # automated-cherry-pick-of--- -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh index e3babbeb41..c47069e3bf 100755 --- a/scripts/docker-start-all.sh +++ b/scripts/docker-start-all.sh @@ -15,7 +15,7 @@ # limitations under the License. -set -o nounset + #fixme This scripts is the total startup scripts diff --git a/scripts/gen-swagger-docs.sh b/scripts/gen-swagger-docs.sh index 311ae8e15e..e768f9106c 100755 --- a/scripts/gen-swagger-docs.sh +++ b/scripts/gen-swagger-docs.sh @@ -16,7 +16,7 @@ # Script to generate docs from the latest swagger spec. -set -o nounset + # The root of the build/dist directory diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 34b4039235..c7cf163202 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -16,7 +16,7 @@ # This script automatically initializes various configuration files and can generate example files. -set -o nounset + # Root directory of the OpenIM project diff --git a/scripts/init-env.sh b/scripts/init-env.sh index 495a8fcf42..1e802c3be4 100755 --- a/scripts/init-env.sh +++ b/scripts/init-env.sh @@ -16,7 +16,7 @@ #FIXME This script is the startup script for multiple servers. #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. -set -o nounset + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P) diff --git a/scripts/install-im-server.sh b/scripts/install-im-server.sh index 426779be05..d11a49dc8d 100755 --- a/scripts/install-im-server.sh +++ b/scripts/install-im-server.sh @@ -28,7 +28,7 @@ # SERVER_IMAGE_VERSION=latest IMAGE_REGISTRY=myregistry ./this_script.sh -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/list-feature-tests.sh b/scripts/list-feature-tests.sh index 7ed19e25dd..d6eaa48731 100755 --- a/scripts/list-feature-tests.sh +++ b/scripts/list-feature-tests.sh @@ -19,7 +19,7 @@ # Usage: `scripts/list-feature-tests.sh`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/release.sh b/scripts/release.sh index ed981a0ed8..eb8b04359f 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -48,7 +48,7 @@ # Build a OpenIM release. This script supports various flags for flexible execution control. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/common.sh" diff --git a/scripts/run-in-gopath.sh b/scripts/run-in-gopath.sh index cbad11d396..6af9869757 100755 --- a/scripts/run-in-gopath.sh +++ b/scripts/run-in-gopath.sh @@ -21,7 +21,7 @@ # Usage: `scripts/run-in-gopath.sh `. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 39c5d1bf2a..0be1d40224 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -16,7 +16,7 @@ #FIXME This script is the startup script for multiple servers. #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 9b2baa23d1..00bcbe9cdb 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -19,7 +19,7 @@ # Encapsulated as: `make stop`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/update-generated-docs.sh b/scripts/update-generated-docs.sh index 84b5c0f8d5..d48a4067be 100755 --- a/scripts/update-generated-docs.sh +++ b/scripts/update-generated-docs.sh @@ -19,7 +19,7 @@ # by default. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/update-yamlfmt.sh b/scripts/update-yamlfmt.sh index e9cfd63e2a..24ec60de91 100755 --- a/scripts/update-yamlfmt.sh +++ b/scripts/update-yamlfmt.sh @@ -15,7 +15,7 @@ -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/verify-pkg-names.sh b/scripts/verify-pkg-names.sh index 1357c6cb7a..7fce3d7adb 100755 --- a/scripts/verify-pkg-names.sh +++ b/scripts/verify-pkg-names.sh @@ -18,7 +18,7 @@ # Usage: `scripts/verify-pkg-names.sh`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/verify-shellcheck.sh b/scripts/verify-shellcheck.sh index 0b8687edbb..c7e713d093 100755 --- a/scripts/verify-shellcheck.sh +++ b/scripts/verify-shellcheck.sh @@ -18,7 +18,7 @@ # Usage: `scripts/verify-shellcheck.sh`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/verify-spelling.sh b/scripts/verify-spelling.sh index d2830f591e..fa0852866d 100755 --- a/scripts/verify-spelling.sh +++ b/scripts/verify-spelling.sh @@ -18,7 +18,7 @@ # Usage: `scripts/verify-spelling.sh`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/verify-typecheck.sh b/scripts/verify-typecheck.sh index 529c353972..c9b2aaf309 100755 --- a/scripts/verify-typecheck.sh +++ b/scripts/verify-typecheck.sh @@ -17,7 +17,7 @@ # Usage: `scripts/verify-typecheck.sh`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/verify-yamlfmt.sh b/scripts/verify-yamlfmt.sh index 636a9c8e43..3acbf457c9 100755 --- a/scripts/verify-yamlfmt.sh +++ b/scripts/verify-yamlfmt.sh @@ -20,7 +20,7 @@ # Usage: `scripts/verify-yamlfmt.sh`. -set -o nounset + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. From b0bcbb6ece80ce849adc78b619d5d07d808d9045 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:16:55 +0800 Subject: [PATCH 04/77] rm set error --- scripts/start-all.sh | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 0be1d40224..b54388d59e 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -22,37 +22,23 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::info "\n# Begin to start all openim service scripts" - -set +o errexit -openim::golang::check_openim_binaries -if [[ $? -ne 0 ]]; then - openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries." - "${OPENIM_ROOT}"/scripts/build-all-service.sh -fi - - -"${OPENIM_ROOT}"/scripts/init-config.sh --skip - -echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTARIES[@]}" -openim::log::install_errexit # Function to execute the scripts. function execute_scripts() { for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do # Extract the script name without extension for argument generation. script_name_with_prefix=$(basename "$script_path" .sh) - + # Remove the "openim-" prefix. script_name=${script_name_with_prefix#openim-} - + # Construct the argument based on the script name. arg="openim::${script_name}::start" - + # Check if the script file exists and is executable. if [[ -x "$script_path" ]]; then openim::log::status "Starting script: ${script_path##*/}" # Log the script name. - + # Execute the script with the constructed argument. result=$("$script_path" "$arg") if [[ $? -ne 0 ]]; then @@ -69,6 +55,23 @@ function execute_scripts() { } + + +openim::log::info "\n# Begin to start all openim service scripts" + + +openim::golang::check_openim_binaries +if [[ $? -ne 0 ]]; then + openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries." + "${OPENIM_ROOT}"/scripts/build-all-service.sh +fi + + +"${OPENIM_ROOT}"/scripts/init-config.sh --skip + +echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTARIES[@]}" + + # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh From 4f790aa0a1fac65efaa9013c814812eb63825a43 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:20:56 +0800 Subject: [PATCH 05/77] rm set error --- scripts/lib/logging.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 0c34be831a..960ba156da 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -76,11 +76,11 @@ openim::log::errexit() { openim::log::install_errexit() { # trap ERR to provide an error handler whenever a command exits nonzero this # is a more verbose version of - trap 'openim::log::errexit' ERR + # trap 'openim::log::errexit' ERR # setting errtrace allows our ERR trap handler to be propagated to functions, # expansions and subshells - set -o errtrace + #set -o errtrace } # Print out the stack trace From 27d88fdf94b81ae6af3968c4c17cb5e823d974fd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:24:19 +0800 Subject: [PATCH 06/77] replace openim::log::info --- scripts/lib/util.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 38f2a29566..2bea0c5921 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -402,7 +402,7 @@ openim::util::check_process_names() { local not_started=() local started=() - openim::log::info "Checking processes: $*" + echo "Checking processes: $*" # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name @@ -1588,7 +1588,7 @@ openim::util::check_ports() { # An array to collect information about processes that are running. local started=() - openim::log::info "Checking ports: $*" + echo "Checking ports: $*" # Iterate over each given port. for port in "$@"; do # Initialize variables @@ -1634,7 +1634,7 @@ openim::util::check_ports() { # Print information about ports whose processes are not running. if [[ ${#not_started[@]} -ne 0 ]]; then - openim::log::info "\n### Not started ports:" + echo "\n### Not started ports:" for port in "${not_started[@]}"; do openim::log::error "Port $port is not started." done @@ -1642,9 +1642,9 @@ openim::util::check_ports() { # Print information about ports whose processes are running. if [[ ${#started[@]} -ne 0 ]]; then - openim::log::info "\n### Started ports:" + echo "\n### Started ports:" for info in "${started[@]}"; do - openim::log::info "$info" + echo "$info" done fi @@ -1693,7 +1693,7 @@ openim::util::check_process_names() { local not_started=() local started=() - openim::log::info "Checking processes: $*" + echo "Checking processes: $*" # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name @@ -1721,7 +1721,7 @@ openim::util::check_process_names() { # Print information if [[ ${#not_started[@]} -ne 0 ]]; then - openim::log::info "Not started processes:" + echo "Not started processes:" for process_name in "${not_started[@]}"; do openim::log::error "Process $process_name is not started." done @@ -1729,9 +1729,9 @@ openim::util::check_process_names() { if [[ ${#started[@]} -ne 0 ]]; then echo - openim::log::info "Started processes:" + echo "Started processes:" for info in "${started[@]}"; do - openim::log::info "$info" + echo "$info" done fi @@ -1764,7 +1764,7 @@ openim::util::stop_services_on_ports() { # An array to collect information about processes that were stopped. local stopped=() - openim::log::info "Stopping services on ports: $*" + echo "Stopping services on ports: $*" # Iterate over each given port. for port in "$@"; do # Use the `lsof` command to find process information related to the given port. @@ -1788,7 +1788,7 @@ openim::util::stop_services_on_ports() { # Print information about ports whose processes couldn't be stopped. if [[ ${#not_stopped[@]} -ne 0 ]]; then - openim::log::info "Ports that couldn't be stopped:" + echo "Ports that couldn't be stopped:" for port in "${not_stopped[@]}"; do openim::log::status "Failed to stop service on port $port." done @@ -1797,7 +1797,7 @@ openim::util::stop_services_on_ports() { # Print information about ports whose processes were successfully stopped. if [[ ${#stopped[@]} -ne 0 ]]; then for port in "${stopped[@]}"; do - openim::log::info "Successfully stopped service on port $port." + echo "Successfully stopped service on port $port." done fi @@ -1830,7 +1830,7 @@ openim::util::stop_services_with_name() { # An array to collect information about processes that were stopped. local stopped=() - openim::log::info "Stopping services with names: $*" + 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. @@ -1867,7 +1867,7 @@ openim::util::stop_services_with_name() { # Print information about services whose processes couldn't be stopped. if [[ ${#not_stopped[@]} -ne 0 ]]; then - openim::log::info "Services that couldn't be stopped:" + echo "Services that couldn't be stopped:" for name in "${not_stopped[@]}"; do openim::log::status "Failed to stop the $name service." done @@ -1876,9 +1876,9 @@ openim::util::stop_services_with_name() { # Print information about services whose processes were successfully stopped. if [[ ${#stopped[@]} -ne 0 ]]; then echo - openim::log::info "Stopped services:" + echo "Stopped services:" for name in "${stopped[@]}"; do - openim::log::info "Successfully stopped the $name service." + echo "Successfully stopped the $name service." done fi From 97191a1c7258a5968ed6480e66a6288f59901515 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:25:13 +0800 Subject: [PATCH 07/77] replace openim::log::info --- scripts/lib/util.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 2bea0c5921..153cf6a0c6 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -298,7 +298,7 @@ openim::util::check_ports() { # An array to collect information about processes that are running. local started=() - openim::log::info "Checking ports: $*" + echo "Checking ports: $*" # Iterate over each given port. for port in "$@"; do # Initialize variables @@ -344,7 +344,7 @@ openim::util::check_ports() { # Print information about ports whose processes are not running. if [[ ${#not_started[@]} -ne 0 ]]; then - openim::log::info "\n### Not started ports:" + echo "\n### Not started ports:" for port in "${not_started[@]}"; do openim::log::error "Port $port is not started." done @@ -352,9 +352,9 @@ openim::util::check_ports() { # Print information about ports whose processes are running. if [[ ${#started[@]} -ne 0 ]]; then - openim::log::info "\n### Started ports:" + echo "\n### Started ports:" for info in "${started[@]}"; do - openim::log::info "$info" + echo "$info" done fi @@ -430,7 +430,7 @@ openim::util::check_process_names() { # Print information if [[ ${#not_started[@]} -ne 0 ]]; then - openim::log::info "Not started processes:" + echo "Not started processes:" for process_name in "${not_started[@]}"; do openim::log::error "Process $process_name is not started." done @@ -438,9 +438,9 @@ openim::util::check_process_names() { if [[ ${#started[@]} -ne 0 ]]; then echo - openim::log::info "Started processes:" + echo "Started processes:" for info in "${started[@]}"; do - openim::log::info "$info" + echo "$info" done fi @@ -477,7 +477,7 @@ openim::util::check_process_names_for_stop() { local not_started=() local started=() - openim::log::info "Checking processes: $*" + echo "Checking processes: $*" # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name @@ -505,7 +505,7 @@ openim::util::check_process_names_for_stop() { # Print information if [[ ${#not_started[@]} -ne 0 ]]; then - openim::log::info "Not started processes:" + echo "Not started processes:" for process_name in "${not_started[@]}"; do openim::log::error "Process $process_name is not started." done @@ -513,9 +513,9 @@ openim::util::check_process_names_for_stop() { if [[ ${#started[@]} -ne 0 ]]; then echo - openim::log::info "Started processes:" + echo "Started processes:" for info in "${started[@]}"; do - openim::log::info "$info" + echo "$info" done fi @@ -548,7 +548,7 @@ openim::util::stop_services_on_ports() { # An array to collect information about processes that were stopped. local stopped=() - openim::log::info "Stopping services on ports: $*" + echo "Stopping services on ports: $*" # Iterate over each given port. for port in "$@"; do # Use the `lsof` command to find process information related to the given port. @@ -572,7 +572,7 @@ openim::util::stop_services_on_ports() { # Print information about ports whose processes couldn't be stopped. if [[ ${#not_stopped[@]} -ne 0 ]]; then - openim::log::info "Ports that couldn't be stopped:" + echo "Ports that couldn't be stopped:" for port in "${not_stopped[@]}"; do openim::log::status "Failed to stop service on port $port." done @@ -581,7 +581,7 @@ openim::util::stop_services_on_ports() { # Print information about ports whose processes were successfully stopped. if [[ ${#stopped[@]} -ne 0 ]]; then for port in "${stopped[@]}"; do - openim::log::info "Successfully stopped service on port $port." + echo "Successfully stopped service on port $port." done fi @@ -614,7 +614,7 @@ openim::util::stop_services_with_name() { # An array to collect information about processes that were stopped. local stopped=() - openim::log::info "Stopping services with names: $*" + 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. From d24e8ba41683b10dbdb4062276f91a382da7f993 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:29:07 +0800 Subject: [PATCH 08/77] replace openim::log::info --- scripts/install/openim-rpc.sh | 1 - scripts/lib/logging.sh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index 95cce7ffa9..976a2146fd 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -130,7 +130,6 @@ function openim::rpc::start() { for ((i = 0; i < ${#OPENIM_RPC_SERVICE_LISTARIES[*]}; i++)); do openim::log::info "OpenIM ${OPENIM_RPC_SERVICE_LISTARIES[$i]} config path: ${OPENIM_RPC_CONFIG}" - # Get the service and Prometheus ports. OPENIM_RPC_SERVICE_PORTS=( $(openim::util::list-to-string ${OPENIM_RPC_PORT_LISTARIES[$i]}) ) read -a OPENIM_RPC_SERVICE_PORTS_ARRAY <<< ${OPENIM_RPC_SERVICE_PORTS} diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 960ba156da..18fe1c9a49 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -81,6 +81,7 @@ openim::log::install_errexit() { # setting errtrace allows our ERR trap handler to be propagated to functions, # expansions and subshells #set -o errtrace + return 0 } # Print out the stack trace From 01d7a9c892994ad93236a15a69c82f183dec8e0c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:34:33 +0800 Subject: [PATCH 09/77] log --- scripts/install/openim-rpc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index 976a2146fd..7d968a7854 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -141,7 +141,7 @@ function openim::rpc::start() { openim::log::info "Starting ${OPENIM_RPC_SERVICE_LISTARIES[$i]} service, port: ${OPENIM_RPC_SERVICE_PORTS[j]}, prometheus port: ${OPENIM_RPC_PROM_PORTS[j]}, binary root: ${OPENIM_OUTPUT_HOSTBIN}/${OPENIM_RPC_SERVICE_LISTARIES[$i]}" result=$(openim::rpc::start_service "${OPENIM_RPC_SERVICE_LISTARIES[$i]}" "${OPENIM_RPC_SERVICE_PORTS[j]}" "${OPENIM_RPC_PROM_PORTS[j]}") if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" + openim::log::error "start ${SERVER_NAME} failed" else openim::log::info "$result" fi From b9d1037b0d734e2aa452cb56e14f904ac9ae7b58 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:37:39 +0800 Subject: [PATCH 10/77] log --- scripts/install/openim-msgtransfer.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index ca4d1086e2..3298e6e788 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -50,11 +50,11 @@ function openim::msgtransfer::start() { openim::log::info "openim maggateway num: ${OPENIM_MSGGATEWAY_NUM}" if [ "${OPENIM_MSGGATEWAY_NUM}" -lt 1 ]; then - opeim::log::error_exit "OPENIM_MSGGATEWAY_NUM must be greater than 0" + opeim::log::error "OPENIM_MSGGATEWAY_NUM must be greater than 0" fi if [ ${OPENIM_MSGGATEWAY_NUM} -ne $((${#MSG_TRANSFER_PROM_PORTS[@]} - 1)) ]; then - openim::log::error_exit "OPENIM_MSGGATEWAY_NUM must be equal to the number of MSG_TRANSFER_PROM_PORTS" + openim::log::error "OPENIM_MSGGATEWAY_NUM must be equal to the number of MSG_TRANSFER_PROM_PORTS" fi for (( i=0; i<$OPENIM_MSGGATEWAY_NUM; i++ )) do @@ -88,7 +88,7 @@ function openim::msgtransfer::check() { fi done else - openim::log::error_exit "Expected $OPENIM_MSGGATEWAY_NUM openim msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes." + openim::log::error "Expected $OPENIM_MSGGATEWAY_NUM openim msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes." fi } From a5dbbe00fcd4ae044853a21feedbfd9be4adedee Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:41:20 +0800 Subject: [PATCH 11/77] log --- scripts/install/openim-push.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 23f4d72e3b..af466cc01f 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -64,7 +64,7 @@ function openim::push::start() { result=$(openim::util::stop_services_with_name ${SERVER_NAME}) if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" + openim::log::error "stop ${SERVER_NAME} failed \n " "${result}" return 1 fi @@ -72,7 +72,7 @@ function openim::push::start() { openim::log::status "prometheus port list: ${PUSH_PROM_PORTS_ARRAY[@]}" if [ ${#OPENIM_PUSH_PORTS_ARRAY[@]} -ne ${#PUSH_PROM_PORTS_ARRAY[@]} ]; then - openim::log::error_exit "The length of the two port lists is different!" + openim::log::error "The length of the two port lists is different!" fi for (( i=0; i<${#OPENIM_PUSH_PORTS_ARRAY[@]}; i++ )); do From bb15d1462720d9d4f990af8b370fdd244d3fab8b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:42:42 +0800 Subject: [PATCH 12/77] log --- scripts/install/openim-rpc.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index 7d968a7854..2d1fc42841 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -148,15 +148,7 @@ function openim::rpc::start() { done done - sleep 5 - - result=$(openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]}) - if [[ $? -ne 0 ]]; then - openim::log::error "check ${SERVER_NAME} failed" - else - openim::log::info "$result" - fi - # openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]} + return 0 } From 812fa38a874021db5a2f79efe1c7d75de5f6997c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:48:17 +0800 Subject: [PATCH 13/77] log --- scripts/install/openim-push.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index af466cc01f..48a298aac1 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -62,9 +62,9 @@ function openim::push::start() { OPENIM_PUSH_PORTS_ARRAY=$(openim::util::list-to-string ${OPENIM_PUSH_PORT} ) PUSH_PROM_PORTS_ARRAY=$(openim::util::list-to-string ${PUSH_PROM_PORT} ) - result=$(openim::util::stop_services_with_name ${SERVER_NAME}) + result=$(openim::util::stop_services_with_name ${OPENIM_PUSH_BINARY}) if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed \n " "${result}" + openim::log::error "stop ${OPENIM_PUSH_BINARY} failed \n " "${result}" return 1 fi From 1993117b15131bb21b6cd85dcf4008b47273fcf2 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:54:20 +0800 Subject: [PATCH 14/77] log --- scripts/install/openim-rpc.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index 2d1fc42841..a099cc8dd3 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -64,6 +64,16 @@ IFS=" " read -ra OPENIM_RPC_SERVICE_TARGETS <<< "$(openim::rpc::service_name)" readonly OPENIM_RPC_SERVICE_TARGETS readonly OPENIM_RPC_SERVICE_LISTARIES=("${OPENIM_RPC_SERVICE_TARGETS[@]##*/}") + +OPENIM_ALL_RPC_FULL_PATH=() +for target in openim::rpc::service_name; do + OPENIM_ALL_RPC_FULL_PATH+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") +done +readonly OPENIM_ALL_RPC_FULL_PATH + + + + # Make sure the environment is only called via common to avoid too much nesting openim::rpc::service_port() { local targets=( @@ -121,11 +131,11 @@ function openim::rpc::start() { printf "+------------------------+-------+-----------------+\n" done - result=$(openim::util::stop_services_with_name ${OPENIM_API_SERVER_LIBRARIES}) + result=$(openim::util::stop_services_with_name ${OPENIM_ALL_RPC_FULL_PATH[@]}) if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" + openim::log::error "stop ${SERVER_NAME} failed" "$result" fi - + sleep 1 # start all rpc services for ((i = 0; i < ${#OPENIM_RPC_SERVICE_LISTARIES[*]}; i++)); do From eee941e68ab6b9add7849c20a87323730199f7ab Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:55:39 +0800 Subject: [PATCH 15/77] log --- scripts/install/openim-rpc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index a099cc8dd3..3d53501317 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -135,7 +135,7 @@ function openim::rpc::start() { if [[ $? -ne 0 ]]; then openim::log::error "stop ${SERVER_NAME} failed" "$result" fi - sleep 1 + sleep 5 # start all rpc services for ((i = 0; i < ${#OPENIM_RPC_SERVICE_LISTARIES[*]}; i++)); do From 92e77042b683a8c2bf278157cf1d443271558d7f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 18:58:50 +0800 Subject: [PATCH 16/77] log --- scripts/start-all.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index b54388d59e..48435d7400 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -78,6 +78,12 @@ TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh openim::log::info "\n## Pre Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start + +"${OPENIM_ROOT}"/scripts/stop-all.sh + +sleep 5 + + openim::log::info "\n## Starting OpenIM services" execute_scripts From a6fbf521f8a3114683990ae6842945e3a6d5b4c6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:00:28 +0800 Subject: [PATCH 17/77] log --- 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 48435d7400..712cd6a04f 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -81,7 +81,7 @@ ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start "${OPENIM_ROOT}"/scripts/stop-all.sh -sleep 5 +sleep 30 openim::log::info "\n## Starting OpenIM services" From 3f19efa26c6c7dedd59c5e9f593b6e4a86a6814b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:06:30 +0800 Subject: [PATCH 18/77] log --- scripts/install/openim-msgtransfer.sh | 2 +- scripts/start-all.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 3298e6e788..72882bafe5 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -75,7 +75,7 @@ function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") NUM_PROCESSES=$(echo "$PIDS" | wc -l) - + echo "111111111111transfer check " "$NUM_PROCESSES" "$OPENIM_MSGGATEWAY_NUM" if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then openim::log::info "Found $OPENIM_MSGGATEWAY_NUM processes named $OPENIM_OUTPUT_HOSTBIN" for PID in $PIDS; do diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 712cd6a04f..8e211e0828 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -92,6 +92,7 @@ sleep 2 openim::log::info "\n## Check OpenIM service name" . $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check + echo "+++ The process being checked:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" From b99ec427d0722ba576fcb1af5fb2c0b9faa9f837 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:17:43 +0800 Subject: [PATCH 19/77] log --- scripts/install/common.sh | 7 +++++-- scripts/lib/golang.sh | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/install/common.sh b/scripts/install/common.sh index 32498d94c7..3b0a342cc4 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -99,14 +99,17 @@ IFS=" " read -ra OPENIM_SERVER_PORT_TARGETS <<< "$(openim::common::service_port) readonly OPENIM_SERVER_PORT_TARGETS readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}") + OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=() -for target in openim::golang::server_targets_no_transfer; do +for target in OPENIM_SERVER_TARGETS_NO_TRANSFER; do OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") done readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER + + OPENIM_ALL_SERVICE_LIBRARIES=() -for target in openim::golang::server_targets; do +for target in OPENIM_SERVER_TARGETS; do OPENIM_ALL_SERVICE_LIBRARIES+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") done readonly OPENIM_ALL_SERVICE_LIBRARIES diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 22bef6bc1b..98f664a3e9 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -102,6 +102,14 @@ openim::golang::server_targets_no_transfer() { echo "${targets[@]}" } + +IFS=" " read -ra OPENIM_SERVER_TARGETS_NO_TRANSFER <<< "$(openim::golang::server_targets_no_transfer)" +readonly OPENIM_SERVER_TARGETS_NO_TRANSFER +readonly OPENIM_SERVER_TARGETS_NO_TRANSFER=("${OPENIM_SERVER_TARGETS_NO_TRANSFER[@]##*/}") + + + + IFS=" " read -ra OPENIM_SERVER_TARGETS <<< "$(openim::golang::server_targets)" readonly OPENIM_SERVER_TARGETS readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}") From 8420de9c7e3942b2a486404b4c7388d6063c5d14 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:23:16 +0800 Subject: [PATCH 20/77] log --- scripts/lib/golang.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 98f664a3e9..1e18ab53d5 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -102,10 +102,9 @@ openim::golang::server_targets_no_transfer() { echo "${targets[@]}" } - IFS=" " read -ra OPENIM_SERVER_TARGETS_NO_TRANSFER <<< "$(openim::golang::server_targets_no_transfer)" readonly OPENIM_SERVER_TARGETS_NO_TRANSFER -readonly OPENIM_SERVER_TARGETS_NO_TRANSFER=("${OPENIM_SERVER_TARGETS_NO_TRANSFER[@]##*/}") +readonly OPENIM_SERVER_BINARIES_NO_TRANSFER=("${OPENIM_SERVER_TARGETS_NO_TRANSFER[@]##*/}") From c38dff14bad0dca694d3563011abcd17e073994c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:25:48 +0800 Subject: [PATCH 21/77] log --- scripts/install/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/common.sh b/scripts/install/common.sh index 3b0a342cc4..3fe0087070 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -101,7 +101,7 @@ readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}") OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=() -for target in OPENIM_SERVER_TARGETS_NO_TRANSFER; do +for target in OPENIM_SERVER_BINARIES_NO_TRANSFER; do OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") done readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER From 40a834a8b6bf6c7f75556eb78f9c60ce303d0275 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:28:40 +0800 Subject: [PATCH 22/77] log --- scripts/install/common.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install/common.sh b/scripts/install/common.sh index 3fe0087070..a3aa8a7fc5 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -103,6 +103,7 @@ readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}") OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=() for target in OPENIM_SERVER_BINARIES_NO_TRANSFER; do OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") + echo "OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER " $OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER $target done readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER From c24f72d090383256b4105a0bf1e63656b4bf9369 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:33:22 +0800 Subject: [PATCH 23/77] log --- scripts/install/common.sh | 5 +++-- scripts/start-all.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install/common.sh b/scripts/install/common.sh index a3aa8a7fc5..41b0adca59 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -101,7 +101,8 @@ readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}") OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=() -for target in OPENIM_SERVER_BINARIES_NO_TRANSFER; do + +for target in "${OPENIM_SERVER_BINARIES_NO_TRANSFER[@]}"; do OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") echo "OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER " $OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER $target done @@ -110,7 +111,7 @@ readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER OPENIM_ALL_SERVICE_LIBRARIES=() -for target in OPENIM_SERVER_TARGETS; do +for target in "${OPENIM_SERVER_TARGETS[@]}"; do OPENIM_ALL_SERVICE_LIBRARIES+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") done readonly OPENIM_ALL_SERVICE_LIBRARIES diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 8e211e0828..ef6b7c154f 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -81,7 +81,7 @@ ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start "${OPENIM_ROOT}"/scripts/stop-all.sh -sleep 30 +sleep 10 openim::log::info "\n## Starting OpenIM services" From 9c7263b0679803942eb3f53bae2958a1b693e83f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:40:00 +0800 Subject: [PATCH 24/77] log --- scripts/install/common.sh | 2 +- scripts/lib/golang.sh | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/scripts/install/common.sh b/scripts/install/common.sh index 41b0adca59..316c5a3598 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -111,7 +111,7 @@ readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER OPENIM_ALL_SERVICE_LIBRARIES=() -for target in "${OPENIM_SERVER_TARGETS[@]}"; do +for target in "${OPENIM_SERVER_BINARIES_NO_CMDUTILS[@]}"; do OPENIM_ALL_SERVICE_LIBRARIES+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") done readonly OPENIM_ALL_SERVICE_LIBRARIES diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 1e18ab53d5..7b9d7e60c0 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -87,7 +87,6 @@ openim::golang::server_targets() { openim::golang::server_targets_no_transfer() { local targets=( openim-api - openim-cmdutils openim-crontask openim-msggateway openim-push @@ -102,6 +101,33 @@ openim::golang::server_targets_no_transfer() { echo "${targets[@]}" } +openim::golang::server_targets_no_cmdutils() { + local targets=( + openim-api + openim-crontask + openim-msggateway + openim-msgtransfer + openim-push + openim-rpc-auth + openim-rpc-conversation + openim-rpc-friend + openim-rpc-group + openim-rpc-msg + openim-rpc-third + openim-rpc-user + ) + echo "${targets[@]}" +} + + +IFS=" " read -ra OPENIM_SERVER_TARGETS_NO_CMDUTILS <<< "$(openim::golang::server_targets_no_cmdutils)" +readonly OPENIM_SERVER_TARGETS_NO_CMDUTILS +readonly OPENIM_SERVER_BINARIES_NO_CMDUTILS=("${OPENIM_SERVER_TARGETS_NO_CMDUTILS[@]##*/}") + + + + + IFS=" " read -ra OPENIM_SERVER_TARGETS_NO_TRANSFER <<< "$(openim::golang::server_targets_no_transfer)" readonly OPENIM_SERVER_TARGETS_NO_TRANSFER readonly OPENIM_SERVER_BINARIES_NO_TRANSFER=("${OPENIM_SERVER_TARGETS_NO_TRANSFER[@]##*/}") From f3812357328a6dc65209a50082655d9ccbafa42f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:41:28 +0800 Subject: [PATCH 25/77] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 00bcbe9cdb..be0c6265c4 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -40,7 +40,7 @@ openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "stop process failed.\n$(result)" + openim::log::error "stop process failed.\n" "${result}" return 1 fi From 063cb44e53369fafeebb2bf7069200ef7cd17de0 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:42:24 +0800 Subject: [PATCH 26/77] log --- scripts/check-all.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 17fb5fb7c8..60e49cf616 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -92,9 +92,7 @@ result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRA if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "check process failed.\n $result" - return 1 else echo "++++ Check all openim service ports successfully !" - return 0 fi From 3ff28111e1772562103e68321db46ae2277ef717 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:43:43 +0800 Subject: [PATCH 27/77] log --- scripts/stop-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index be0c6265c4..2120c53456 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -41,7 +41,7 @@ result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "stop process failed.\n" "${result}" - return 1 +else + openim::log::success "✨ All processes to be stopped" fi -openim::log::success "✨ All processes to be stopped" \ No newline at end of file From 21aa278ad30d1ef1e25c74b3f7de7fbf14040882 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:45:04 +0800 Subject: [PATCH 28/77] log --- scripts/install/openim-msgtransfer.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 72882bafe5..bc16bfa97f 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -33,13 +33,7 @@ function openim::msgtransfer::start() { openim::log::info "Start OpenIM Msggateway, binary root: ${SERVER_NAME}" openim::log::status "Start OpenIM Msggateway, path: ${OPENIM_MSGTRANSFER_BINARY}" - - result=$(openim::util::stop_services_with_name ${OPENIM_MSGTRANSFER_BINARY}) - if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" - return 1 - fi - + # Message Transfer Prometheus port list MSG_TRANSFER_PROM_PORTS=(openim::util::list-to-string ${MSG_TRANSFER_PROM_PORT} ) From e9b9b7247e55ea6d37af2ae79f89f4222708628b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:51:13 +0800 Subject: [PATCH 29/77] log --- scripts/lib/util.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 153cf6a0c6..44bfa663ca 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2883,17 +2883,20 @@ function openim::util::gen_os_arch() { function openim::util::check_process_names_for_stop() { local all_stopped=true - + echo "dddddddddddddddddddddddddddddddddddd" for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do + echo "dddddddddddddddddddddddddddddddddddd" ${server} + PIDS=$(pgrep -f "${service}") || PIDS="0" if [ "$PIDS" = "0" ]; then continue fi - all_stopped=false - NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) + NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) + echo "dddddddddddddddddddddddddddddddddddd" ${NUM_PROCESSES} if [ "$NUM_PROCESSES" -gt 0 ]; then + all_stopped=false openim::log::error "Found $NUM_PROCESSES processes for ${service}" for PID in $PIDS; do if [[ "$OSTYPE" == "linux-gnu"* ]]; then From f776e991e873318f31b47fd59f3f9c178cc6f3d6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 19:53:50 +0800 Subject: [PATCH 30/77] log --- scripts/lib/util.sh | 2 +- scripts/stop-all.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 44bfa663ca..271606c416 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2885,7 +2885,7 @@ function openim::util::check_process_names_for_stop() { local all_stopped=true echo "dddddddddddddddddddddddddddddddddddd" for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do - echo "dddddddddddddddddddddddddddddddddddd" ${server} + echo "dddddddddddddddddddddddddddddddddddd" ${service} PIDS=$(pgrep -f "${service}") || PIDS="0" if [ "$PIDS" = "0" ]; then diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 2120c53456..f3457f5992 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -35,7 +35,7 @@ openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" - +sleep 5 result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then From c61a79a9f75a1f944278502f90840926bf1f50f1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:11:16 +0800 Subject: [PATCH 31/77] log --- scripts/check-all.sh | 16 +++++++++----- scripts/install/openim-api.sh | 8 +------ scripts/install/openim-crontask.sh | 8 +------ scripts/install/openim-msggateway.sh | 7 +----- scripts/install/openim-msgtransfer.sh | 5 ++--- scripts/install/openim-push.sh | 8 +------ scripts/install/openim-rpc.sh | 6 +---- scripts/start-all.sh | 32 ++++++++++++++++++--------- scripts/stop-all.sh | 32 ++++++++++++++++++--------- 9 files changed, 60 insertions(+), 62 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 60e49cf616..3fe0866c83 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -80,19 +80,25 @@ else echo "++++ Check all dependent service ports successfully !" fi -openim::log::info "\n## Check OpenIM service name" -. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check -openim::log::info "\n## Check all OpenIM service ports" -echo "+++ The process being checked:" +openim::log::info "\n## Check OpenIM service name ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) +if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "check process failed.\n $result" +fi + + +echo "Check OpenIM service name:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" done + result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "check process failed.\n $result" else - echo "++++ Check all openim service ports successfully !" + echo "Check all openim service ports successfully !" fi diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index 933fef2ce8..8a7b8d1f11 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -48,11 +48,7 @@ function openim::api::start() { openim::log::info "Starting ${SERVER_NAME} ..." readonly OPENIM_API_SERVER_LIBRARIES="${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME}" - result=$(openim::util::stop_services_with_name ${OPENIM_API_SERVER_LIBRARIES}) - if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" - return 1 - fi + printf "+------------------------+--------------+\n" printf "| Service Name | Port |\n" @@ -64,8 +60,6 @@ function openim::api::start() { printf "| %-22s | %6s |\n" "${OPENIM_API_SERVICE_LISTARIES[$i]}" "${OPENIM_API_PORT_LISTARIES[$i]}" printf "+------------------------+--------------+\n" # Stop services on the specified ports before starting new ones -# openim::util::stop_services_on_ports "${OPENIM_API_PORT_LISTARIES[$i]}" -# openim::util::stop_services_on_ports "${OPENIM_API_PROMETHEUS_PORT_LISTARIES[$i]}" openim::log::info "OpenIM ${OPENIM_API_SERVICE_LISTARIES[$i]} config path: ${OPENIM_API_CONFIG}" # Start the service with Prometheus port if specified diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh index b139cb14ab..ae78a44dd4 100755 --- a/scripts/install/openim-crontask.sh +++ b/scripts/install/openim-crontask.sh @@ -49,13 +49,7 @@ function openim::crontask::start() { openim::log::info "Start OpenIM Cron, binary root: ${SERVER_NAME}" openim::log::status "Start OpenIM Cron, path: ${OPENIM_CRONTASK_BINARY}" - - result=$(openim::util::stop_services_with_name ${OPENIM_CRONTASK_BINARY}) - if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" - return 1 - fi - + openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}" nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index 79bdee2229..1515381015 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -31,12 +31,7 @@ function openim::msggateway::start() { openim::log::info "Start OpenIM Msggateway, binary root: ${SERVER_NAME}" openim::log::status "Start OpenIM Msggateway, path: ${OPENIM_MSGGATEWAY_BINARY}" - - result=$(openim::util::stop_services_with_name ${OPENIM_MSGGATEWAY_BINARY}) - if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" - return 1 - fi + # OpenIM message gateway service port OPENIM_MESSAGE_GATEWAY_PORTS=$(openim::util::list-to-string ${OPENIM_MESSAGE_GATEWAY_PORT} ) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index bc16bfa97f..4abf9b5e2b 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -67,11 +67,8 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") - NUM_PROCESSES=$(echo "$PIDS" | wc -l) - echo "111111111111transfer check " "$NUM_PROCESSES" "$OPENIM_MSGGATEWAY_NUM" if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then - openim::log::info "Found $OPENIM_MSGGATEWAY_NUM processes named $OPENIM_OUTPUT_HOSTBIN" for PID in $PIDS; do if [[ "$OSTYPE" == "linux-gnu"* ]]; then ps -p $PID -o pid,cmd @@ -83,7 +80,9 @@ function openim::msgtransfer::check() { done else openim::log::error "Expected $OPENIM_MSGGATEWAY_NUM openim msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes." + return 1 fi + return 0 } function openim::msgtransfer::check_for_stop() { diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 48a298aac1..8684f185c1 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -61,13 +61,7 @@ function openim::push::start() { OPENIM_PUSH_PORTS_ARRAY=$(openim::util::list-to-string ${OPENIM_PUSH_PORT} ) PUSH_PROM_PORTS_ARRAY=$(openim::util::list-to-string ${PUSH_PROM_PORT} ) - - result=$(openim::util::stop_services_with_name ${OPENIM_PUSH_BINARY}) - if [[ $? -ne 0 ]]; then - openim::log::error "stop ${OPENIM_PUSH_BINARY} failed \n " "${result}" - return 1 - fi - + openim::log::status "push port list: ${OPENIM_PUSH_PORTS_ARRAY[@]}" openim::log::status "prometheus port list: ${PUSH_PROM_PORTS_ARRAY[@]}" diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index 3d53501317..023cb65947 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -131,11 +131,7 @@ function openim::rpc::start() { printf "+------------------------+-------+-----------------+\n" done - result=$(openim::util::stop_services_with_name ${OPENIM_ALL_RPC_FULL_PATH[@]}) - if [[ $? -ne 0 ]]; then - openim::log::error "stop ${SERVER_NAME} failed" "$result" - fi - sleep 5 + # start all rpc services for ((i = 0; i < ${#OPENIM_RPC_SERVICE_LISTARIES[*]}; i++)); do diff --git a/scripts/start-all.sh b/scripts/start-all.sh index ef6b7c154f..e1c9ea2386 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -24,7 +24,7 @@ source "${OPENIM_ROOT}/scripts/install/common.sh" # Function to execute the scripts. -function execute_scripts() { +function execute_start_scripts() { for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do # Extract the script name without extension for argument generation. script_name_with_prefix=$(basename "$script_path" .sh) @@ -79,26 +79,36 @@ openim::log::info "\n## Pre Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start -"${OPENIM_ROOT}"/scripts/stop-all.sh +result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) +if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "Some programs have not exited; the start process is aborted .\n $result" + exit 1 +fi -sleep 10 openim::log::info "\n## Starting OpenIM services" -execute_scripts +execute_start_scripts -sleep 2 -openim::log::info "\n## Check OpenIM service name" -. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check +sleep 2 +result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) +if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "The program may fail to start.\n $result" + exit 1 +fi -echo "+++ The process being checked:" -for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do - echo "$item" -done openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} +if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "The program may fail to start.\n $result" + exit 1 +fi + openim::log::info "\n## Post Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index f3457f5992..b0070ae68d 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -34,14 +34,24 @@ openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES - -sleep 5 - -result=$(openim::util::check_process_names_for_stop) -if [[ $? -ne 0 ]]; then - echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "stop process failed.\n" "${result}" -else - openim::log::success "✨ All processes to be stopped" -fi - +max_retries=15 +attempt=0 + +while [[ $attempt -lt $max_retries ]] +do + result=$(openim::util::check_process_names_for_stop) + + if [[ $? -ne 0 ]]; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "stop process failed. continue waiting\n" "${result}" + sleep 1 + ((attempt++)) + + else + openim::log::success "✨ All processes to be stopped" + exit 0 + fi +done + +openim::log::error "✨ openim processes stopped failed" +exit 1 From 8d4734c4e38ca81dc413d4cefb807dd9137f1acd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:18:34 +0800 Subject: [PATCH 32/77] log --- scripts/check-all.sh | 2 +- scripts/lib/util.sh | 25 +++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 3fe0866c83..da32978603 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -81,7 +81,7 @@ else fi -openim::log::info "\n## Check OpenIM service name ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check OpenIM service name: ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 271606c416..10825eab94 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -503,33 +503,18 @@ openim::util::check_process_names_for_stop() { fi done - # Print information - if [[ ${#not_started[@]} -ne 0 ]]; then - echo "Not started processes:" - for process_name in "${not_started[@]}"; do - openim::log::error "Process $process_name is not started." - done - fi if [[ ${#started[@]} -ne 0 ]]; then echo - echo "Started processes:" + echo "The programs that have not exited are:" for info in "${started[@]}"; do - echo "$info" + echo "$info " done - fi - - # Return status - if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" - cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 - else - echo "" - openim::log::success "All processes are running." - return 0 fi + + return 0 + } # openim::util::check_process_names docker-pr From d95a52fba29b99cdffa48c69e83d02a063fa7e36 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:21:21 +0800 Subject: [PATCH 33/77] log --- scripts/stop-all.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index b0070ae68d..ffba4c70e9 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -33,6 +33,8 @@ echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES +sleep 1 + max_retries=15 attempt=0 @@ -46,7 +48,6 @@ do openim::log::error "stop process failed. continue waiting\n" "${result}" sleep 1 ((attempt++)) - else openim::log::success "✨ All processes to be stopped" exit 0 From 58efba12b5862be34929200cc15630cb007dc5a8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:22:37 +0800 Subject: [PATCH 34/77] log --- scripts/install/common.sh | 1 - scripts/lib/util.sh | 3 --- 2 files changed, 4 deletions(-) diff --git a/scripts/install/common.sh b/scripts/install/common.sh index 316c5a3598..ed1ba1a4bb 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -104,7 +104,6 @@ OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER=() for target in "${OPENIM_SERVER_BINARIES_NO_TRANSFER[@]}"; do OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER+=("${OPENIM_OUTPUT_HOSTBIN}/${target}") - echo "OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER " $OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER $target done readonly OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 10825eab94..d6c540604b 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2868,9 +2868,7 @@ function openim::util::gen_os_arch() { function openim::util::check_process_names_for_stop() { local all_stopped=true - echo "dddddddddddddddddddddddddddddddddddd" for service in "${OPENIM_ALL_SERVICE_LIBRARIES[@]}"; do - echo "dddddddddddddddddddddddddddddddddddd" ${service} PIDS=$(pgrep -f "${service}") || PIDS="0" if [ "$PIDS" = "0" ]; then @@ -2879,7 +2877,6 @@ function openim::util::check_process_names_for_stop() { NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) - echo "dddddddddddddddddddddddddddddddddddd" ${NUM_PROCESSES} if [ "$NUM_PROCESSES" -gt 0 ]; then all_stopped=false openim::log::error "Found $NUM_PROCESSES processes for ${service}" From bba27c3dd3c19f4e70ee20f1401bd3bc5aa9b749 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:31:39 +0800 Subject: [PATCH 35/77] log --- scripts/start-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index e1c9ea2386..08c64a32e4 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -90,7 +90,7 @@ fi openim::log::info "\n## Starting OpenIM services" execute_start_scripts - +openim::log::info "\n## Starting OpenIM services finish !!!!!!!!!!!!!!!!" sleep 2 @@ -102,7 +102,7 @@ if [[ $? -ne 0 ]]; then fi -openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} +result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "The program may fail to start.\n $result" From 80c4b6ce7b88d9f217fdeb1d5cca9560222b282b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:37:45 +0800 Subject: [PATCH 36/77] log --- scripts/start-all.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 08c64a32e4..0787e45925 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -90,7 +90,6 @@ fi openim::log::info "\n## Starting OpenIM services" execute_start_scripts -openim::log::info "\n## Starting OpenIM services finish !!!!!!!!!!!!!!!!" sleep 2 @@ -113,4 +112,4 @@ fi openim::log::info "\n## Post Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::color::echo $COLOR_BLUE "✨ All OpenIM services have been successfully started!" \ No newline at end of file +openim::color::echo $COLOR_GREEN "✨ All OpenIM services have been successfully started!" \ No newline at end of file From 690266ce5c509e035b44a851025c1229f35f8b00 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:45:09 +0800 Subject: [PATCH 37/77] log --- scripts/check-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index da32978603..01f80ecdde 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -99,6 +99,6 @@ if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "check process failed.\n $result" else - echo "Check all openim service ports successfully !" + openim::color::echo $COLOR_GREEN "All openim services are running normally! " fi From 25d87bf7741e2fd808ca113e756909ddd8b10647 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:46:21 +0800 Subject: [PATCH 38/77] log --- scripts/check-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 01f80ecdde..49d23895ce 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -81,7 +81,7 @@ else fi -openim::log::info "\n## Check OpenIM service name: ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check OpenIM service name: \n ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" From 0ae63365012b67b7072dc22e5ae16b51fdd74e5f Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 21:48:24 +0800 Subject: [PATCH 39/77] fix: fix the error output format --- pkg/util/genutil/genutil.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/util/genutil/genutil.go b/pkg/util/genutil/genutil.go index f97b803f66..70709be57e 100644 --- a/pkg/util/genutil/genutil.go +++ b/pkg/util/genutil/genutil.go @@ -15,7 +15,6 @@ package genutil import ( - "errors" "fmt" "os" "path/filepath" @@ -42,11 +41,8 @@ func OutDir(path string) (string, error) { } func ExitWithError(err error) { - if errors.Is(err, errors.New("SIGTERM EXIT")) { - os.Exit(-1) - } progName := filepath.Base(os.Args[0]) - fmt.Fprintf(os.Stderr, "\n\n%s exit -1: \n%+v\n\n", progName, err) + fmt.Fprintf(os.Stderr, "%s exit -1: %+v\n", progName, err) os.Exit(-1) } From 0bc93fcba1d8fb4b9263f5855643e04561c21784 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:50:40 +0800 Subject: [PATCH 40/77] log --- scripts/lib/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index d6c540604b..14f671aa06 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -344,7 +344,7 @@ openim::util::check_ports() { # Print information about ports whose processes are not running. if [[ ${#not_started[@]} -ne 0 ]]; then - echo "\n### Not started ports:" + echo "### Not started ports:" for port in "${not_started[@]}"; do openim::log::error "Port $port is not started." done @@ -352,7 +352,7 @@ openim::util::check_ports() { # Print information about ports whose processes are running. if [[ ${#started[@]} -ne 0 ]]; then - echo "\n### Started ports:" + echo "### Started ports:" for info in "${started[@]}"; do echo "$info" done From 706b0d94e1f6374661e3619991db09b8b24c0953 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 21:54:18 +0800 Subject: [PATCH 41/77] fix: fix the error --- internal/msggateway/init.go | 4 +--- pkg/common/startrpc/start.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/msggateway/init.go b/internal/msggateway/init.go index 321407f7ee..b18efcd50d 100644 --- a/internal/msggateway/init.go +++ b/internal/msggateway/init.go @@ -46,9 +46,7 @@ func RunWsAndServer(rpcPort, wsPort, prometheusPort int) error { netDone := make(chan error) go func() { err = hubServer.Start() - if err != nil { - netDone <- err - } + netDone <- err }() return hubServer.LongConnServer.Run(netDone) } diff --git a/pkg/common/startrpc/start.go b/pkg/common/startrpc/start.go index c5105ec513..6bcdcca5de 100644 --- a/pkg/common/startrpc/start.go +++ b/pkg/common/startrpc/start.go @@ -152,7 +152,7 @@ func Start( if err != nil { return errs.Wrap(err, "shutdown err") } - return errors.New("SIGTERM EXIT") + return nil case <-netDone: close(netDone) return netErr From 585cc934219985f5601815d1fff10e31a1f42041 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 21:54:37 +0800 Subject: [PATCH 42/77] log --- scripts/check-all.sh | 2 +- scripts/lib/util.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 49d23895ce..ca43876d4d 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -77,7 +77,7 @@ if [[ $? -ne 0 ]]; then openim::log::error_exit "The service does not start properly, please check the port, query variable definition!" echo "+++ https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh +++" else - echo "++++ Check all dependent service ports successfully !" + openim::color::echo $COLOR_GREEN "All components depended on by openim are running normally! " fi diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 14f671aa06..6cf5a03430 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -365,7 +365,7 @@ openim::util::check_ports() { cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 else - openim::log::success "All specified processes are running." + #openim::log::success "All specified ports are running." return 0 fi } From a8ed65b0419200032856fa0a998239eee6476be7 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:02:01 +0800 Subject: [PATCH 43/77] log --- scripts/install/openim-msgtransfer.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 4abf9b5e2b..72b71c935f 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -23,8 +23,6 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh -openim::util::set_max_fd 200000 - SERVER_NAME="openim-msgtransfer" function openim::msgtransfer::start() { From f3b27abc4312c0cb86ae70cc631f46bb154c29d1 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 22:03:00 +0800 Subject: [PATCH 44/77] fix: fi the code error --- cmd/openim-api/main.go | 2 +- internal/msgtransfer/init.go | 2 +- pkg/common/startrpc/start.go | 2 +- pkg/util/genutil/genutil.go | 4 ++-- scripts/install/openim-msggateway.sh | 1 - scripts/install/openim-msgtransfer.sh | 1 - 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index 7a7e062939..34ada1d579 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -119,7 +119,7 @@ func run(port int, proPort int) error { defer cancel() select { case <-sigs: - util.SIGUSR1Exit() + util.SIGTERMExit() err := server.Shutdown(ctx) if err != nil { return errs.Wrap(err, "shutdown err") diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go index 16d8613dbf..ac545f1985 100644 --- a/internal/msgtransfer/init.go +++ b/internal/msgtransfer/init.go @@ -144,7 +144,7 @@ func (m *MsgTransfer) Start(prometheusPort int) error { signal.Notify(sigs, syscall.SIGTERM) select { case <-sigs: - util.SIGUSR1Exit() + util.SIGTERMExit() // graceful close kafka client. m.cancel() m.historyCH.historyConsumerGroup.Close() diff --git a/pkg/common/startrpc/start.go b/pkg/common/startrpc/start.go index 6bcdcca5de..be9fbd25bf 100644 --- a/pkg/common/startrpc/start.go +++ b/pkg/common/startrpc/start.go @@ -140,7 +140,7 @@ func Start( signal.Notify(sigs, syscall.SIGTERM) select { case <-sigs: - util.SIGUSR1Exit() + util.SIGTERMExit() ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() if err := gracefulStopWithCtx(ctx, srv.GracefulStop); err != nil { diff --git a/pkg/util/genutil/genutil.go b/pkg/util/genutil/genutil.go index 70709be57e..bd9376d583 100644 --- a/pkg/util/genutil/genutil.go +++ b/pkg/util/genutil/genutil.go @@ -46,7 +46,7 @@ func ExitWithError(err error) { os.Exit(-1) } -func SIGUSR1Exit() { +func SIGTERMExit() { progName := filepath.Base(os.Args[0]) - fmt.Printf("\n\n%s receive process terminal SIGTERM exit 0\n\n", progName) + fmt.Fprintf(os.Stderr, "Warning %s receive process terminal SIGTERM exit 0\n", progName) } diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index 1515381015..3eb9bb3495 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -21,7 +21,6 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh -openim::util::set_max_fd 200000 SERVER_NAME="openim-msggateway" diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 4abf9b5e2b..d18f6a77c8 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -23,7 +23,6 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh -openim::util::set_max_fd 200000 SERVER_NAME="openim-msgtransfer" From 0011542d297bd1dbbcd709829bf2c875482a134c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:03:41 +0800 Subject: [PATCH 45/77] log --- scripts/install/openim-msgtransfer.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 72b71c935f..6b8b8b78dc 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -65,6 +65,8 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") + echo "transsssssssssssssssssssssss" $PIDS + NUM_PROCESSES=$(echo "$PIDS" | wc -l) if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then for PID in $PIDS; do From 559c4ecd245761fa1534dd55bda4b939aa4c0277 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:04:45 +0800 Subject: [PATCH 46/77] log --- scripts/install/openim-msgtransfer.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 6b8b8b78dc..569cb03d52 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -66,7 +66,8 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") echo "transsssssssssssssssssssssss" $PIDS - + echo "$PIDS" | wc -l + echo "tdddddddddddddddddranssssssssssssssssssssssss" $PIDS NUM_PROCESSES=$(echo "$PIDS" | wc -l) if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then for PID in $PIDS; do From 7a3e02b4cc903c2aeebdc70419f85337d08b96bd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:06:22 +0800 Subject: [PATCH 47/77] log --- scripts/install/openim-msgtransfer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 569cb03d52..41e8549099 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -65,7 +65,7 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") - echo "transsssssssssssssssssssssss" $PIDS + echo "transsssssssssssssssssssssss" [$PIDS] echo "$PIDS" | wc -l echo "tdddddddddddddddddranssssssssssssssssssssssss" $PIDS NUM_PROCESSES=$(echo "$PIDS" | wc -l) From c806549f5959f43fe5008f61bbc187bbce9c917a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:08:38 +0800 Subject: [PATCH 48/77] log --- scripts/install/openim-msgtransfer.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 41e8549099..9fdf07fe20 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -65,10 +65,11 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") - echo "transsssssssssssssssssssssss" [$PIDS] - echo "$PIDS" | wc -l - echo "tdddddddddddddddddranssssssssssssssssssssssss" $PIDS - NUM_PROCESSES=$(echo "$PIDS" | wc -l) + if [ -z "$PIDS" ]; then + NUM_PROCESSES=0 + else + NUM_PROCESSES=$(echo "$PIDS" | wc -l) + fi if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then for PID in $PIDS; do if [[ "$OSTYPE" == "linux-gnu"* ]]; then From c0dddb4d010c34eb4787c1e35fe1667651cc2e03 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:13:47 +0800 Subject: [PATCH 49/77] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 6cf5a03430..ac0f8d77cb 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -432,7 +432,7 @@ openim::util::check_process_names() { if [[ ${#not_started[@]} -ne 0 ]]; then echo "Not started processes:" for process_name in "${not_started[@]}"; do - openim::log::error "Process $process_name is not started." + #openim::log::error "Process $process_name is not started." done fi From 14a0b8e272851b5b3667761c68da44a9be47a5c6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:14:35 +0800 Subject: [PATCH 50/77] log --- scripts/check-all.sh | 3 ++- scripts/lib/util.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index ca43876d4d..9e353bb937 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -97,7 +97,8 @@ done result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "check process failed.\n $result" + openim::log::error "check process failed.\n " + echo "$result" else openim::color::echo $COLOR_GREEN "All openim services are running normally! " fi diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index ac0f8d77cb..6cf5a03430 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -432,7 +432,7 @@ openim::util::check_process_names() { if [[ ${#not_started[@]} -ne 0 ]]; then echo "Not started processes:" for process_name in "${not_started[@]}"; do - #openim::log::error "Process $process_name is not started." + openim::log::error "Process $process_name is not started." done fi From 5c0062964494c6b8523976b91742adc5d9423776 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:15:13 +0800 Subject: [PATCH 51/77] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 6cf5a03430..b9d29fd968 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -432,7 +432,7 @@ openim::util::check_process_names() { if [[ ${#not_started[@]} -ne 0 ]]; then echo "Not started processes:" for process_name in "${not_started[@]}"; do - openim::log::error "Process $process_name is not started." + echo "Process $process_name is not started." done fi From 9bba016a8cba414a2f02e129b554cd7e4369d47e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:16:11 +0800 Subject: [PATCH 52/77] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index b9d29fd968..3f61a2df97 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -477,7 +477,7 @@ openim::util::check_process_names_for_stop() { local not_started=() local started=() - echo "Checking processes: $*" + # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name From c176cf594ba59bf300d3f26a60c5b40c965fa974 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:17:04 +0800 Subject: [PATCH 53/77] log --- scripts/lib/util.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 3f61a2df97..b5442d9cb4 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -402,7 +402,6 @@ openim::util::check_process_names() { local not_started=() local started=() - echo "Checking processes: $*" # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name From a84dbac876c34c88b42d549114bb5b7805331aa8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:21:00 +0800 Subject: [PATCH 54/77] log --- scripts/stop-all.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index ffba4c70e9..fd156cc0ff 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -33,7 +33,7 @@ echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES -sleep 1 + max_retries=15 @@ -44,9 +44,11 @@ do result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then - echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "stop process failed. continue waiting\n" "${result}" - sleep 1 + if [[$attempt -ne 0 ]] ; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "stop process failed. continue waiting\n" "${result}" + fi + sleep 1 ((attempt++)) else openim::log::success "✨ All processes to be stopped" From 795b003210ffeb16c6348dc4315dcf73435f3c4b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:22:55 +0800 Subject: [PATCH 55/77] log --- scripts/check-all.sh | 2 +- scripts/start-all.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 9e353bb937..0a85777241 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -100,6 +100,6 @@ if [[ $? -ne 0 ]]; then openim::log::error "check process failed.\n " echo "$result" else - openim::color::echo $COLOR_GREEN "All openim services are running normally! " + openim::log::success "All openim services are running normally! " fi diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 0787e45925..3cc4d982f3 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -109,7 +109,7 @@ if [[ $? -ne 0 ]]; then fi -openim::log::info "\n## Post Starting OpenIM services" +openim::log::info "\n## Post Starting openim services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::color::echo $COLOR_GREEN "✨ All OpenIM services have been successfully started!" \ No newline at end of file +openim::log::success "✨ All openim services have been successfully started!" \ No newline at end of file From 2c48d848db47d7f0b3c2bf92d5f0bc5bcc77f2ef Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:23:51 +0800 Subject: [PATCH 56/77] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index fd156cc0ff..328392d29d 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -51,7 +51,7 @@ do sleep 1 ((attempt++)) else - openim::log::success "✨ All processes to be stopped" + openim::log::success "✨ All openim processes to be stopped" exit 0 fi done From 202a1fff733dffa42de9ccce813bece6423dbf08 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:26:57 +0800 Subject: [PATCH 57/77] log --- scripts/start-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 3cc4d982f3..4ba09d1350 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -57,7 +57,7 @@ function execute_start_scripts() { -openim::log::info "\n# Begin to start all openim service scripts" + openim::golang::check_openim_binaries @@ -88,7 +88,7 @@ fi -openim::log::info "\n## Starting OpenIM services" +openim::log::info "\n## Starting openim services" execute_start_scripts sleep 2 From 169b7feafd96a1e5c49894f65fbec9f16e819bbc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:27:23 +0800 Subject: [PATCH 58/77] log --- 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 4ba09d1350..22fbf4a79a 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -112,4 +112,4 @@ fi openim::log::info "\n## Post Starting openim services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::log::success "✨ All openim services have been successfully started!" \ No newline at end of file +openim::log::success "All openim services have been successfully started!" \ No newline at end of file From b8c930d1519b7524d3115ad2fc00e33cfae8419f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:28:51 +0800 Subject: [PATCH 59/77] log --- 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 22fbf4a79a..f6a4a2ea7f 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -88,7 +88,7 @@ fi -openim::log::info "\n## Starting openim services" +openim::log::info "\n## Starting openim script " execute_start_scripts sleep 2 From dd846a4993b9026fb0c34697984ba34352e05661 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:30:03 +0800 Subject: [PATCH 60/77] log --- scripts/start-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index f6a4a2ea7f..67735ac1ac 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -37,7 +37,7 @@ function execute_start_scripts() { # Check if the script file exists and is executable. if [[ -x "$script_path" ]]; then - openim::log::status "Starting script: ${script_path##*/}" # Log the script name. + openim::log::info "Starting script: ${script_path##*/}" # Log the script name. # Execute the script with the constructed argument. result=$("$script_path" "$arg") @@ -75,7 +75,7 @@ echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTAR # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::info "\n## Pre Starting OpenIM services" +openim::log::status "\n## Pre Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start From 001308cebf656cef59ee4b343dc553c0e7448ea5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:31:10 +0800 Subject: [PATCH 61/77] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 328392d29d..1792efc6df 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -44,7 +44,7 @@ do result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then - if [[$attempt -ne 0 ]] ; then + if [[ $attempt -ne 0 ]] ; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "stop process failed. continue waiting\n" "${result}" fi From ea4afc6e122ca014bb2689c00512fea398aeec3c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:32:08 +0800 Subject: [PATCH 62/77] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 1792efc6df..451f77f6c4 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -45,7 +45,7 @@ do if [[ $? -ne 0 ]]; then if [[ $attempt -ne 0 ]] ; then - echo "+++ cat openim log file >>> ${LOG_FILE}" + echo "+++ cat openim log file >>> ${LOG_FILE} " $attempt openim::log::error "stop process failed. continue waiting\n" "${result}" fi sleep 1 From de2eea713106bac87ee20829b40d56306b92a932 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:34:47 +0800 Subject: [PATCH 63/77] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index b5442d9cb4..69182bd7d6 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2888,7 +2888,7 @@ function openim::util::check_process_names_for_stop() { openim::log::error "Unsupported OS type: $OSTYPE" fi done - openim::log::error "Processes for ${service} have not been stopped properly." + openim::log::error "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" fi done From 9a2c74baaad4399639f0b528067ae2e64b6aea5a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:37:03 +0800 Subject: [PATCH 64/77] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 69182bd7d6..2cd3cc432b 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2888,7 +2888,7 @@ function openim::util::check_process_names_for_stop() { openim::log::error "Unsupported OS type: $OSTYPE" fi done - openim::log::error "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" + echo "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" fi done From df87f9405e8a5ecad658bb15315d40905b6f1835 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:38:09 +0800 Subject: [PATCH 65/77] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 2cd3cc432b..023edc344c 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2878,7 +2878,7 @@ function openim::util::check_process_names_for_stop() { NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) if [ "$NUM_PROCESSES" -gt 0 ]; then all_stopped=false - openim::log::error "Found $NUM_PROCESSES processes for ${service}" + echo "Found $NUM_PROCESSES processes for ${service}" for PID in $PIDS; do if [[ "$OSTYPE" == "linux-gnu"* ]]; then echo -e "\033[31m$(ps -p $PID -o pid,cmd)\033[0m" From 4c07027cf2df656989b2b13d98bbcf83390b5044 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:39:19 +0800 Subject: [PATCH 66/77] log --- 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 67735ac1ac..9a98bfca3a 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -88,7 +88,7 @@ fi -openim::log::info "\n## Starting openim script " +openim::log::status "\n## Starting openim scripts: " execute_start_scripts sleep 2 From 96d493e732cce6eb35fe0dcb4669ae5490f47e63 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:41:34 +0800 Subject: [PATCH 67/77] log --- scripts/lib/logging.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 18fe1c9a49..a6ec5ff226 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -213,15 +213,20 @@ openim::log::status() { done } + openim::log::success() { local V="${V:-0}" if [[ ${OPENIM_VERBOSE} < ${V} ]]; then return fi - timestamp=$(date +"%m%d %H:%M:%S") - echo_log -e "${COLOR_GREEN}[success ${timestamp}] ${COLOR_SUFFIX}==> " "$@" + local timestamp=$(date +"%m%d %H:%M:%S") + local reset_color='\033[0m' + echo_log -e "${COLOR_GREEN}[success ${timestamp}]${COLOR_SUFFIX}==> ${COLOR_GREEN}$@${reset_color}" } + + + function openim::log::test_log() { echo_log "test log" openim::log::info "openim::log::info" From 7a1d4612b72c19d2aeaa1793556408d3d3619cc8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:43:14 +0800 Subject: [PATCH 68/77] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 451f77f6c4..e7f0f47e06 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -26,7 +26,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::info "\n# Begin to stop all openim service" +openim::log::stat "\n# Begin to stop all openim service" echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" From 3b0a4bab2e324fc2850a44cd7f6f3188de61d5ff Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:43:51 +0800 Subject: [PATCH 69/77] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index e7f0f47e06..28b3b04bb8 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -26,7 +26,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::stat "\n# Begin to stop all openim service" +openim::log::status "\n# Begin to stop all openim service" echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" From e09475dd3171e54a39946d6f51dc9a1da6ea9e40 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:45:12 +0800 Subject: [PATCH 70/77] log --- scripts/stop-all.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 28b3b04bb8..9b37696acd 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -28,7 +28,7 @@ source "${OPENIM_ROOT}/scripts/install/common.sh" openim::log::status "\n# Begin to stop all openim service" -echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" +openim::log::status "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES @@ -51,10 +51,10 @@ do sleep 1 ((attempt++)) else - openim::log::success "✨ All openim processes to be stopped" + openim::log::success " All openim processes to be stopped" exit 0 fi done -openim::log::error "✨ openim processes stopped failed" +openim::log::error "openim processes stopped failed" exit 1 From 488c3a7c4775ecdf5150b7b2cc191b574216027c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:46:00 +0800 Subject: [PATCH 71/77] log --- scripts/stop-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 9b37696acd..b2572f7d5e 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -26,9 +26,9 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::status "\n# Begin to stop all openim service" +openim::log::status "Begin to stop all openim service" -openim::log::status "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" +openim::log::status "Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES From d9e7523a2fa871fa6d2ae734e28944bc018e25cd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:47:19 +0800 Subject: [PATCH 72/77] log --- scripts/lib/logging.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index a6ec5ff226..7afb6bfced 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -206,7 +206,7 @@ openim::log::status() { fi timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") - echo_log "+++ ${timestamp} ${1}" + echo_log "${timestamp} ${1}" shift for message; do echo_log " ${message}" From 6b927060f23b4c20bc009b912f6f3dc5192a64a3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:49:59 +0800 Subject: [PATCH 73/77] log --- scripts/lib/util.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 023edc344c..8da6692823 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -360,8 +360,8 @@ openim::util::check_ports() { # If any of the processes is not running, return a status of 1. if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 else @@ -445,8 +445,8 @@ openim::util::check_process_names() { # Return status if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 else @@ -1634,8 +1634,8 @@ openim::util::check_ports() { # If any of the processes is not running, return a status of 1. if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" echo "" cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 From 83fb847d3db961018dddedb7896c472349ba0b05 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:51:29 +0800 Subject: [PATCH 74/77] log --- scripts/check-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 0a85777241..759db029a0 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -81,7 +81,7 @@ else fi -openim::log::info "\n## Check OpenIM service name: \n ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check OpenIM service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" From 51ca0512b465a7b0526ca2e36e0e7b325b76180e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:51:59 +0800 Subject: [PATCH 75/77] log --- scripts/check-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 759db029a0..1a92f3f69e 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -81,7 +81,7 @@ else fi -openim::log::info "\n## Check OpenIM service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check openim service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" @@ -89,7 +89,7 @@ if [[ $? -ne 0 ]]; then fi -echo "Check OpenIM service name:" +echo "Check openim service name:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" done From 716c5c668bdd7191af4a36839e9aee006e30f294 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:55:00 +0800 Subject: [PATCH 76/77] log --- scripts/check-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 1a92f3f69e..a9b07d65b3 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -77,7 +77,7 @@ if [[ $? -ne 0 ]]; then openim::log::error_exit "The service does not start properly, please check the port, query variable definition!" echo "+++ https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh +++" else - openim::color::echo $COLOR_GREEN "All components depended on by openim are running normally! " + openim::log::success "All components depended on by openim are running normally! " fi From beeae4956d228aa596eee09f2a0b450dccdfaeae Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Tue, 27 Feb 2024 10:17:52 +0800 Subject: [PATCH 77/77] fix: use printf replace the echo --- internal/msgtransfer/init.go | 4 +--- scripts/lib/util.sh | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go index ac545f1985..add3c197a9 100644 --- a/internal/msgtransfer/init.go +++ b/internal/msgtransfer/init.go @@ -149,7 +149,7 @@ func (m *MsgTransfer) Start(prometheusPort int) error { m.cancel() m.historyCH.historyConsumerGroup.Close() m.historyMongoCH.historyConsumerGroup.Close() - + return nil case <-netDone: m.cancel() m.historyCH.historyConsumerGroup.Close() @@ -157,6 +157,4 @@ func (m *MsgTransfer) Start(prometheusPort int) error { close(netDone) return netErr } - - return nil } diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 6cf5a03430..5dcb85bcb0 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -1619,7 +1619,7 @@ openim::util::check_ports() { # Print information about ports whose processes are not running. if [[ ${#not_started[@]} -ne 0 ]]; then - echo "\n### Not started ports:" + printf "\n### Not started ports:" for port in "${not_started[@]}"; do openim::log::error "Port $port is not started." done @@ -1627,7 +1627,7 @@ openim::util::check_ports() { # Print information about ports whose processes are running. if [[ ${#started[@]} -ne 0 ]]; then - echo "\n### Started ports:" + printf "\n### Started ports:" for info in "${started[@]}"; do echo "$info" done