From c895f1fd9390362ec00cab8cd73c421c35b7a37d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 10:53:16 +0800 Subject: [PATCH 01/90] Optimizing scripts --- pkg/common/db/mgo/conversation.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/common/db/mgo/conversation.go b/pkg/common/db/mgo/conversation.go index bd8cb24e1..981a0f2f0 100644 --- a/pkg/common/db/mgo/conversation.go +++ b/pkg/common/db/mgo/conversation.go @@ -79,7 +79,6 @@ func (c *ConversationMgo) FindUserID(ctx context.Context, userIDs []string, conv options.Find().SetProjection(bson.M{"_id": 0, "owner_user_id": 1}), ) } - func (c *ConversationMgo) FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error) { return mgoutil.Find[string](ctx, c.coll, bson.M{"owner_user_id": userID}, options.Find().SetProjection(bson.M{"_id": 0, "conversation_id": 1})) } From 18ed3028d6f30e1f8bc6ed9f509047c796b360af Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 11:03:22 +0800 Subject: [PATCH 02/90] Delete obsolete script --- scripts/docker-check-service.sh | 91 --------------------------------- 1 file changed, 91 deletions(-) delete mode 100755 scripts/docker-check-service.sh diff --git a/scripts/docker-check-service.sh b/scripts/docker-check-service.sh deleted file mode 100755 index 30ca89b5a..000000000 --- a/scripts/docker-check-service.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env bash - -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -source "${OPENIM_ROOT}/scripts/install/common.sh" - -cd "$OPENIM_ROOT" - -openim::util::check_docker_and_compose_versions - -progress() { - local _main_pid="$1" - local _length=20 - local _ratio=1 - local _colors=("31" "32" "33" "34" "35" "36" "37") - local _wave=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" "▇" "▆" "▅" "▄" "▃" "▂") - - while pgrep -P "$_main_pid" &> /dev/null; do - local _mark='>' - local _progress_bar= - for ((i = 1; i <= _length; i++)); do - if ((i > _ratio)); then - _mark='-' - fi - _progress_bar="${_progress_bar}${_mark}" - done - - local _color_idx=$((_ratio % ${#_colors[@]})) - local _color_prefix="\033[${_colors[_color_idx]}m" - local _reset_suffix="\033[0m" - - local _wave_idx=$((_ratio % ${#_wave[@]})) - local _wave_progress=${_wave[_wave_idx]} - - printf "Progress: ${_color_prefix}${_progress_bar}${_reset_suffix} ${_wave_progress} Countdown: %2ds \r" "$_countdown" - ((_ratio++)) - ((_ratio > _length)) && _ratio=1 - sleep 0.1 - done -} - -countdown() { - local _duration="$1" - - for ((i = _duration; i >= 1; i--)); do - printf "\rCountdown: %2ds \r" "$i" - sleep 1 - done - printf "\rCountdown: %2ds \r" "$_duration" -} - -do_sth() { - echo "++++++++++++++++++++++++" - progress $$ & - local _progress_pid=$! - local _countdown=30 - - countdown "$_countdown" & - local _countdown_pid=$! - - sleep 30 - - kill "$_progress_pid" "$_countdown_pid" - - "${SCRIPTS_ROOT}/check-all.sh" - echo -e "${PURPLE_PREFIX}=========> Check docker-compose status ${COLOR_SUFFIX} \n" -} - -set -e - -do_sth & -do_sth_pid=$(jobs -p | tail -1) - -progress "${do_sth_pid}" & -progress_pid=$(jobs -p | tail -1) - -wait "${do_sth_pid}" -printf "Progress: done \n" From 2a18e9c955424bdb144686ceb8bc7512b9a7402c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 11:07:01 +0800 Subject: [PATCH 03/90] Optimizing scripts --- 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 952995032..af19647bf 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -83,7 +83,7 @@ fi # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::print_blue "\n## Pre Starting OpenIM services" +openim::log::status "\n## Pre Starting OpenIM services" @@ -93,7 +93,7 @@ if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then fi -openim::log::print_blue "Pre Starting OpenIM services processed successfully" +openim::log::status "Pre Starting OpenIM services processed successfully" result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then From 4862503bef3249ef11d506566507d0c736ab79c9 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 11:21:13 +0800 Subject: [PATCH 04/90] Optimizing scripts --- scripts/init-config.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/init-config.sh b/scripts/init-config.sh index c5b21d061..ef2cd0a40 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -65,6 +65,8 @@ GENERATE_EXAMPLES=false CLEAN_CONFIG=false CLEAN_EXAMPLES=false +FILES_PROCESSED=false + # Function to display help information show_help() { echo "Usage: $(basename "$0") [options]" @@ -126,7 +128,7 @@ process_file() { if [[ "${FORCE_OVERWRITE}" == true ]]; then openim::log::info "Force overwriting ${output_file}." elif [[ "${SKIP_EXISTING}" == true ]]; then - openim::log::info "Skipping generation of ${output_file} as it already exists." + #openim::log::info "Skipping generation of ${output_file} as it already exists." return else echo -n "File ${output_file} already exists. Overwrite? (Y/N): " @@ -173,8 +175,7 @@ process_file() { exit 1 } fi - - sleep 0.5 + FILES_PROCESSED=true } clean_config_files() { @@ -259,4 +260,6 @@ if [[ "${GENERATE_EXAMPLES}" == true ]] && [[ "${CLEAN_EXAMPLES}" == false ]]; t generate_example_files fi -openim::log::success "Configuration and example files operation complete!" +if [[ "${FILES_PROCESSED}" == true ]]; then + openim::log::success "Configuration and example files operation complete!" +fi From 4653143c732264c61c884a459707fed1610c0205 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 11:53:13 +0800 Subject: [PATCH 05/90] Optimizing scripts --- scripts/start-all.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index af19647bf..b698af0b1 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -83,17 +83,16 @@ fi # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::status "\n## Pre Starting OpenIM services" - +openim::log::status "Start the preprocessing tools:" if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then - openim::log::error "Pre Starting OpenIM services failed, aborting..." + openim::log::error "Start the preprocessing tools, aborting!" exit 1 fi -openim::log::status "Pre Starting OpenIM services processed successfully" +openim::log::status "Preprocessing has been successfully completed." result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then @@ -104,7 +103,7 @@ fi -openim::log::status "\n## Starting openim scripts: " +openim::log::status "Start the OpenIM startup scripts: " execute_start_scripts sleep 2 From ac41b0730c865a324803c604840eafcd8e9837ce Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 11:59:32 +0800 Subject: [PATCH 06/90] Optimizing scripts --- 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 fec71b19d..ccba11c13 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -215,10 +215,10 @@ openim::log::status() { echo_log "${timestamp} ${1}" shift for message; do - echo_log " ${message}" + echo_log -e "${COLOR_GREEN} ${message} ==> ${COLOR_GREEN}$@${reset_color}" done } - +COLOR_BLUE openim::log::success() { local V="${V:-0}" From 2956462a46683216acedcfe2aa02c7acb67149ea Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 12:17:29 +0800 Subject: [PATCH 07/90] Optimizing scripts --- 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 ccba11c13..239bda40f 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -218,7 +218,7 @@ openim::log::status() { echo_log -e "${COLOR_GREEN} ${message} ==> ${COLOR_GREEN}$@${reset_color}" done } -COLOR_BLUE + openim::log::success() { local V="${V:-0}" @@ -227,7 +227,7 @@ openim::log::success() { fi 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}" + echo_log -e "${COLOR_BLUE}[success ${timestamp}]${COLOR_SUFFIX}==> ${COLOR_BLUE}$@${reset_color}" } From 581164d9c655ee8365cffb33aca5565b8082fc61 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 12:19:36 +0800 Subject: [PATCH 08/90] Optimizing scripts --- scripts/lib/logging.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 239bda40f..6468faf26 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -215,6 +215,7 @@ openim::log::status() { echo_log "${timestamp} ${1}" shift for message; do + local reset_color='\033[0m' echo_log -e "${COLOR_GREEN} ${message} ==> ${COLOR_GREEN}$@${reset_color}" done } From a1d5bdfaa5a28eebba26b6ffce34bc5c37fbe902 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:32:09 +0800 Subject: [PATCH 09/90] Optimizing scripts --- 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 6468faf26..5617b8baf 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -216,7 +216,7 @@ openim::log::status() { shift for message; do local reset_color='\033[0m' - echo_log -e "${COLOR_GREEN} ${message} ==> ${COLOR_GREEN}$@${reset_color}" + echo_log -e "${COLOR_BLUE} ${message} ==> ${COLOR_BLUE}$@${reset_color}" done } @@ -228,7 +228,7 @@ openim::log::success() { fi local timestamp=$(date +"%m%d %H:%M:%S") local reset_color='\033[0m' - echo_log -e "${COLOR_BLUE}[success ${timestamp}]${COLOR_SUFFIX}==> ${COLOR_BLUE}$@${reset_color}" + echo_log -e "${COLOR_GREEN}[success ${timestamp}]${COLOR_SUFFIX}==> ${COLOR_GREEN}$@${reset_color}" } From 84d3b69ae09a3f4b5eb56fcbc8e3b868b82b4b67 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:34:16 +0800 Subject: [PATCH 10/90] Optimizing scripts --- scripts/lib/logging.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 5617b8baf..c18fc4e42 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -210,14 +210,9 @@ openim::log::status() { if [[ ${OPENIM_VERBOSE} < ${V} ]]; then return fi - timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") echo_log "${timestamp} ${1}" - shift - for message; do - local reset_color='\033[0m' - echo_log -e "${COLOR_BLUE} ${message} ==> ${COLOR_BLUE}$@${reset_color}" - done + echo_log -e "${COLOR_BLUE} ${1} ==> ${COLOR_BLUE}$@${reset_color}" } From 9f7bfeff8f83884fdaa61bbd9ce1a6301cb26eda Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:36:03 +0800 Subject: [PATCH 11/90] Optimizing scripts --- scripts/lib/logging.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index c18fc4e42..284138a91 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -211,8 +211,7 @@ openim::log::status() { return fi timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") - echo_log "${timestamp} ${1}" - echo_log -e "${COLOR_BLUE} ${1} ==> ${COLOR_BLUE}$@${reset_color}" + echo_log -e "${COLOR_BLUE} ${timestamp} ${1} ==> ${COLOR_BLUE}$@${reset_color}" } From 04ccfa575e60199d92127f9a2f194c04d779ac2f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:37:07 +0800 Subject: [PATCH 12/90] Optimizing scripts --- 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 284138a91..4c12e4997 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -211,7 +211,7 @@ openim::log::status() { return fi timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") - echo_log -e "${COLOR_BLUE} ${timestamp} ${1} ==> ${COLOR_BLUE}$@${reset_color}" + echo_log -e "${COLOR_BLUE}${timestamp} ${1} ${COLOR_BLUE}$@${reset_color}" } From 2bf3c781ebb1c334e5bc7c8f5603295caa5f3e85 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:42:14 +0800 Subject: [PATCH 13/90] Optimizing scripts --- scripts/install/openim-tools.sh | 6 +++--- scripts/lib/logging.sh | 11 +++++++++++ scripts/start-all.sh | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 7f6e1f52b..53f12973a 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -129,15 +129,15 @@ function openim::tools::start() { function openim::tools::pre-start() { - openim::log::info "Preparing to start OpenIM Tools..." + #openim::log::info "Preparing to start OpenIM Tools..." for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do - openim::log::info "Starting tool ${tool}..." + openim::log::colorless "Starting tool: ${tool}" if ! openim::tools::start_service ${tool} ${OPNEIM_CONFIG}; then openim::log::error "Failed to start ${tool}, aborting..." return 1 fi done - openim::log::info "All tools started successfully." + #openim::log::info "All tools started successfully." } function openim::tools::post-start() { diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 4c12e4997..4cabc1a78 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -244,3 +244,14 @@ function openim::log::print_blue() { echo -e "\033[0;36m$1\033[0m" } + +openim::log::colorless() { + local V="${V:-0}" + if [[ ${OPENIM_VERBOSE} < ${V} ]]; then + return + fi + timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") + echo_log -e "${timestamp} ${1} " +} + + diff --git a/scripts/start-all.sh b/scripts/start-all.sh index b698af0b1..76c2be6c8 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -92,7 +92,7 @@ if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then fi -openim::log::status "Preprocessing has been successfully completed." +openim::log::success "Preprocessing has been successfully completed." result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then From 48cb270a926f22b585394dc344d75962d16409a6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:49:37 +0800 Subject: [PATCH 14/90] Optimizing scripts --- scripts/lib/logging.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 4cabc1a78..0d15463eb 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -210,11 +210,26 @@ openim::log::status() { if [[ ${OPENIM_VERBOSE} < ${V} ]]; then return fi - timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") - echo_log -e "${COLOR_BLUE}${timestamp} ${1} ${COLOR_BLUE}$@${reset_color}" + + local COLOR_BLUE="\033[0;34m" + local COLOR_RESET="\033[0m" + + local timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") + + echo_log() { + echo -e "$@" + } + + + echo_log "${COLOR_BLUE}${timestamp} ${1}${COLOR_RESET}" + shift + for message; do + echo_log "${COLOR_BLUE}${message}${COLOR_RESET}" + done } + openim::log::success() { local V="${V:-0}" if [[ ${OPENIM_VERBOSE} < ${V} ]]; then @@ -227,7 +242,6 @@ openim::log::success() { - function openim::log::test_log() { echo_log "test log" openim::log::info "openim::log::info" From ce9d10d016d65048e53c0465d5fe923b4f4983b1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:53:17 +0800 Subject: [PATCH 15/90] Optimizing scripts --- scripts/install/openim-tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 53f12973a..7f481daab 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -102,7 +102,7 @@ function openim::tools::start_service() { openim::log::status "Starting binary ${binary_name}..." - +openim::log::info "start: $cmd" ${cmd} From d0d5b694f872e23760a94a0a7522e729959e016e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 14:55:09 +0800 Subject: [PATCH 16/90] Optimizing scripts --- scripts/install/openim-tools.sh | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 7f481daab..3a4580af2 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -83,39 +83,36 @@ function openim::tools::start_service() { local prometheus_port="$4" local cmd="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${binary_name}" - openim::log::info "Starting PATH: ${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${binary_name}..." + #openim::log::info "Starting PATH: ${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${binary_name}..." if [ -n "${config}" ]; then - printf "Specifying config: %s\n" "${config}" + # printf "Specifying config: %s\n" "${config}" cmd="${cmd} -c ${config}/config.yaml" fi if [ -n "${service_port}" ]; then - printf "Specifying service port: %s\n" "${service_port}" + #printf "Specifying service port: %s\n" "${service_port}" cmd="${cmd} --port ${service_port}" fi if [ -n "${prometheus_port}" ]; then - printf "Specifying prometheus port: %s\n" "${prometheus_port}" + #printf "Specifying prometheus port: %s\n" "${prometheus_port}" cmd="${cmd} --prometheus_port ${prometheus_port}" fi - openim::log::status "Starting binary ${binary_name}..." - - -openim::log::info "start: $cmd" - ${cmd} + #openim::log::status "Starting binary ${binary_name}..." + openim::log::info "cmd: $cmd" + ${cmd} local status=$? - - if [ $status -eq 0 ]; then - openim::log::info "Service ${binary_name} started successfully." - return 0 - else - openim::log::error "Failed to start service ${binary_name}." - return 1 - fi + if [ $status -eq 0 ]; then + openim::log::info "Service ${binary_name} started successfully." + return 0 + else + openim::log::error "Failed to start service ${binary_name}." + return 1 + fi } function openim::tools::start() { From f0c6cd9a5a1b696d16aba5ca2bc430b8a1dd3173 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:02:51 +0800 Subject: [PATCH 17/90] Optimizing scripts --- scripts/install/openim-tools.sh | 9 +++++---- scripts/lib/golang.sh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 3a4580af2..419af6354 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -103,11 +103,12 @@ function openim::tools::start_service() { openim::log::info "cmd: $cmd" - ${cmd} + ${cmd} > /dev/null 2>&1 + local status=$? if [ $status -eq 0 ]; then - openim::log::info "Service ${binary_name} started successfully." + openim::log::success "Service ${binary_name} started successfully." return 0 else openim::log::error "Failed to start service ${binary_name}." @@ -120,7 +121,7 @@ function openim::tools::start() { for tool in "${OPENIM_TOOLS_NAME_LISTARIES[@]}"; do openim::log::info "Starting tool ${tool}..." # openim::tools::start_service ${tool} - sleep 0.2 + #sleep 0.2 done } @@ -128,7 +129,7 @@ function openim::tools::start() { function openim::tools::pre-start() { #openim::log::info "Preparing to start OpenIM Tools..." for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do - openim::log::colorless "Starting tool: ${tool}" + #openim::log::colorless "Starting tool: ${tool}" if ! openim::tools::start_service ${tool} ${OPNEIM_CONFIG}; then openim::log::error "Failed to start ${tool}, aborting..." return 1 diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 7b9d7e60c..57ce507ee 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() { done return 1 else - echo "All binaries have been installed in ${OPENIM_OUTPUT_HOSTBIN}。" + echo "All binaries have been installed in: ${OPENIM_OUTPUT_HOSTBIN}" return 0 fi } From 5afe9854af9bcfd7c00c656595cb8b221c5a1033 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:06:12 +0800 Subject: [PATCH 18/90] Optimizing scripts --- scripts/install/openim-tools.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 419af6354..aa8bfaaa1 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -102,8 +102,8 @@ function openim::tools::start_service() { #openim::log::status "Starting binary ${binary_name}..." - openim::log::info "cmd: $cmd" - ${cmd} > /dev/null 2>&1 + # openim::log::info "cmd: $cmd" + ${cmd} > /dev/null local status=$? From 1169ebf8cf5079dc331d09288c8bf6679eee814d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:08:31 +0800 Subject: [PATCH 19/90] Optimizing scripts --- scripts/install/openim-tools.sh | 2 +- scripts/start-all.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index aa8bfaaa1..8cd5d15d3 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -129,7 +129,7 @@ function openim::tools::start() { function openim::tools::pre-start() { #openim::log::info "Preparing to start OpenIM Tools..." for tool in "${OPENIM_TOOLS_PRE_START_NAME_LISTARIES[@]}"; do - #openim::log::colorless "Starting tool: ${tool}" + openim::log::colorless "Starting tool: ${tool}" if ! openim::tools::start_service ${tool} ${OPNEIM_CONFIG}; then openim::log::error "Failed to start ${tool}, aborting..." return 1 diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 76c2be6c8..6f5ec6857 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -83,7 +83,7 @@ fi # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::status "Start the preprocessing tools:" +openim::log::status "Start the preprocessing tools" if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then @@ -92,7 +92,7 @@ if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then fi -openim::log::success "Preprocessing has been successfully completed." +openim::log::success "Preprocessing has been successfully completed!" result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then From e100661f6e586cfe334064709b61f3d2e9be79af Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:11:14 +0800 Subject: [PATCH 20/90] Optimizing scripts --- 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 6f5ec6857..2c288d9c5 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -42,7 +42,7 @@ function execute_start_scripts() { # Check if the script file exists and is executable. if [[ -x "$script_path" ]]; then - openim::log::print_blue "Starting script: ${script_path##*/}" # Log the script name. + openim::log::colorless "Starting script: ${script_path##*/}" # Log the script name. # Execute the script with the constructed argument. result=$("$script_path" "$arg") @@ -83,7 +83,7 @@ fi # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::status "Start the preprocessing tools" +openim::log::status "Start the preprocessing tools:" if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then From 1138e373ef8aada366a1000e468cf65d6ff3fa5c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:18:40 +0800 Subject: [PATCH 21/90] Optimizing scripts --- scripts/install/openim-tools.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 8cd5d15d3..237f3d4ce 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -103,7 +103,7 @@ function openim::tools::start_service() { # openim::log::info "cmd: $cmd" - ${cmd} > /dev/null + ${cmd} local status=$? @@ -139,7 +139,7 @@ function openim::tools::pre-start() { } function openim::tools::post-start() { - openim::log::info "Post-start actions for OpenIM Tools..." + #openim::log::info "Post-start actions for OpenIM Tools..." for tool in "${OPENIM_TOOLS_POST_START_NAME_LISTARIES[@]}"; do openim::log::info "Starting tool ${tool}..." openim::tools::start_service ${tool} From f25227807bd7b54b5534074a7791d1977fe17383 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:21:37 +0800 Subject: [PATCH 22/90] Optimizing scripts --- tools/versionchecker/versionchecker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go index 5dd25ddc4..abda33319 100644 --- a/tools/versionchecker/versionchecker.go +++ b/tools/versionchecker/versionchecker.go @@ -53,7 +53,7 @@ func getGoVersion() string { func getDockerVersion() string { version, err := ExecuteCommand("docker", "--version") if err != nil { - return "Docker is not installed. Please install it to get the version." + return "Docker is not installed. Please install it to get the version." + err.Error() } return version } From a6013fc50639be2937888e34e99fb0c5de635add Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:29:01 +0800 Subject: [PATCH 23/90] Optimizing scripts --- tools/versionchecker/versionchecker.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go index abda33319..324ac508d 100644 --- a/tools/versionchecker/versionchecker.go +++ b/tools/versionchecker/versionchecker.go @@ -53,15 +53,7 @@ func getGoVersion() string { func getDockerVersion() string { version, err := ExecuteCommand("docker", "--version") if err != nil { - return "Docker is not installed. Please install it to get the version." + err.Error() - } - return version -} - -func getDockerComposeVersion() string { - version, err := ExecuteCommand("docker-compose", "--version") - if err != nil { - return "Docker Compose is not installed. Please install it to get the version." + return "Docker is not installed. Please install it to get the version." } return version } @@ -112,7 +104,6 @@ func main() { fmt.Println(blue("## Docker Version")) fmt.Println(getDockerVersion()) fmt.Println(blue("## Docker Compose Version")) - fmt.Println(getDockerComposeVersion()) fmt.Println(blue("## Kubernetes Version")) fmt.Println(getKubernetesVersion()) // fmt.Println(blue("## OpenIM Versions")) From 65ba534946c008b2c3a6efb9e991db458b10a479 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:29:44 +0800 Subject: [PATCH 24/90] Optimizing scripts --- tools/versionchecker/versionchecker.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go index 324ac508d..4165b54d1 100644 --- a/tools/versionchecker/versionchecker.go +++ b/tools/versionchecker/versionchecker.go @@ -103,7 +103,6 @@ func main() { fmt.Println(getGitVersion()) fmt.Println(blue("## Docker Version")) fmt.Println(getDockerVersion()) - fmt.Println(blue("## Docker Compose Version")) fmt.Println(blue("## Kubernetes Version")) fmt.Println(getKubernetesVersion()) // fmt.Println(blue("## OpenIM Versions")) From 4fd2e0e5406d6db711f06d3fde48e4d69259a605 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:31:31 +0800 Subject: [PATCH 25/90] Optimizing scripts --- tools/versionchecker/versionchecker.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go index 4165b54d1..4f552b143 100644 --- a/tools/versionchecker/versionchecker.go +++ b/tools/versionchecker/versionchecker.go @@ -95,8 +95,7 @@ func main() { blue := color.New(color.FgBlue).SprintFunc() yellow := color.New(color.FgYellow).SprintFunc() - fmt.Println(green(printTime())) - fmt.Println(yellow("# Diagnostic Tool Result\n")) + fmt.Println(yellow("# Diagnostic Tool Result")) fmt.Println(blue("## Go Version")) fmt.Println(getGoVersion()) fmt.Println(blue("## Branch Type")) From 735dd7af7833cbfddfb2ebdae4ce79d84363ad89 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:33:30 +0800 Subject: [PATCH 26/90] Optimizing scripts --- tools/versionchecker/versionchecker.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go index 4f552b143..7a66b8e26 100644 --- a/tools/versionchecker/versionchecker.go +++ b/tools/versionchecker/versionchecker.go @@ -91,11 +91,9 @@ func getGitVersion() string { func main() { // red := color.New(color.FgRed).SprintFunc() - green := color.New(color.FgGreen).SprintFunc() + // green := color.New(color.FgGreen).SprintFunc() blue := color.New(color.FgBlue).SprintFunc() - yellow := color.New(color.FgYellow).SprintFunc() - - fmt.Println(yellow("# Diagnostic Tool Result")) + // yellow := color.New(color.FgYellow).SprintFunc() fmt.Println(blue("## Go Version")) fmt.Println(getGoVersion()) fmt.Println(blue("## Branch Type")) From 604586c3baefcc1d874f249f7ab93db73325d10e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:40:35 +0800 Subject: [PATCH 27/90] Optimizing scripts --- scripts/install/openim-tools.sh | 4 ++-- scripts/start-all.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index 237f3d4ce..dfbc871af 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -108,7 +108,7 @@ function openim::tools::start_service() { local status=$? if [ $status -eq 0 ]; then - openim::log::success "Service ${binary_name} started successfully." + openim::log::colorless "Service ${binary_name} started successfully." return 0 else openim::log::error "Failed to start service ${binary_name}." @@ -141,7 +141,7 @@ function openim::tools::pre-start() { function openim::tools::post-start() { #openim::log::info "Post-start actions for OpenIM Tools..." for tool in "${OPENIM_TOOLS_POST_START_NAME_LISTARIES[@]}"; do - openim::log::info "Starting tool ${tool}..." + openim::log::info "Starting tool: ${tool}" openim::tools::start_service ${tool} done } diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 2c288d9c5..661a7e01b 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -122,7 +122,7 @@ if [[ $? -ne 0 ]]; then fi -openim::log::info "\n## Post Starting openim services" +openim::log::info "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 From 55552294608b6c4a06c89767649bf6a5ad8c7be3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:44:20 +0800 Subject: [PATCH 28/90] Optimizing scripts --- 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 661a7e01b..a70803d70 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -92,7 +92,7 @@ if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then fi -openim::log::success "Preprocessing has been successfully completed!" +openim::log::colorless "Preprocessing has been successfully completed!" result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then From 892a3701a5c8c0cc0d46bab70eb87e9ae5cc2f92 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:48:30 +0800 Subject: [PATCH 29/90] Optimizing scripts --- scripts/lib/golang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 57ce507ee..6186c17f1 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() { done return 1 else - echo "All binaries have been installed in: ${OPENIM_OUTPUT_HOSTBIN}" + echo "All binaries have been installed in: ${OPENIM_OUTPUT_HOSTBIN} ${OPENIM_OUTPUT_HOSTBIN_TOOLS}" return 0 fi } From b3c2cfe9e0d6676b788055f48575c0251a7833f1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:49:16 +0800 Subject: [PATCH 30/90] Optimizing scripts --- scripts/lib/golang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 6186c17f1..b9da42c9c 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() { done return 1 else - echo "All binaries have been installed in: ${OPENIM_OUTPUT_HOSTBIN} ${OPENIM_OUTPUT_HOSTBIN_TOOLS}" + echo "All binaries have been installed in: ${OPENIM_OUTPUT_HOSTBIN} and ${OPENIM_OUTPUT_HOSTBIN_TOOLS}" return 0 fi } From 7e21e1e63088358f241366ccc4aa5452e9f9334a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:49:55 +0800 Subject: [PATCH 31/90] Optimizing scripts --- scripts/lib/golang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index b9da42c9c..2bd4b650b 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() { done return 1 else - echo "All binaries have been installed in: ${OPENIM_OUTPUT_HOSTBIN} and ${OPENIM_OUTPUT_HOSTBIN_TOOLS}" + echo "All binaries have been installed in: \n ${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}" return 0 fi } From e0a93205c49cd4313995c1854f3dc77ec2d2b3cb Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:51:03 +0800 Subject: [PATCH 32/90] Optimizing scripts --- scripts/lib/golang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 2bd4b650b..d80bb1113 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() { done return 1 else - echo "All binaries have been installed in: \n ${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}" + echo -e "All binaries have been installed in: \n ${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}" return 0 fi } From b2758d93c1bcbde186a68dab3687855f7850640c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:51:32 +0800 Subject: [PATCH 33/90] Optimizing scripts --- scripts/lib/golang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index d80bb1113..54521cbc1 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() { done return 1 else - echo -e "All binaries have been installed in: \n ${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}" + echo -e "All binaries have been installed in: \n${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}" return 0 fi } From 6f5464e34f1bd9c0ae721f284e98c1bc5cdc659b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:54:38 +0800 Subject: [PATCH 34/90] Optimizing scripts --- scripts/install/openim-tools.sh | 2 +- scripts/start-all.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index dfbc871af..a310bf54c 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -119,7 +119,7 @@ function openim::tools::start_service() { function openim::tools::start() { openim::log::info "Starting OpenIM Tools..." for tool in "${OPENIM_TOOLS_NAME_LISTARIES[@]}"; do - openim::log::info "Starting tool ${tool}..." + openim::log::colorless "Starting tool ${tool}..." # openim::tools::start_service ${tool} #sleep 0.2 done diff --git a/scripts/start-all.sh b/scripts/start-all.sh index a70803d70..1816cffb3 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -83,16 +83,16 @@ fi # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::status "Start the preprocessing tools:" +openim::log::status "Start the pre-start tools:" if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then - openim::log::error "Start the preprocessing tools, aborting!" + openim::log::error "Start the pre-start tools, aborting!" exit 1 fi -openim::log::colorless "Preprocessing has been successfully completed!" +openim::log::colorless "pre-start has been successfully completed!" result=$("${OPENIM_ROOT}"/scripts/stop-all.sh) if [[ $? -ne 0 ]]; then @@ -122,7 +122,7 @@ if [[ $? -ne 0 ]]; then fi -openim::log::info "Post Starting openim services" +openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start openim::log::success "All openim services have been successfully started!" \ No newline at end of file From fa52224a0a882cb5078db190d7e1ab519660e5ec Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 15:59:49 +0800 Subject: [PATCH 35/90] Optimizing scripts --- tools/infra/infra.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/infra/infra.go b/tools/infra/infra.go index bc01a00eb..f6225a352 100644 --- a/tools/infra/infra.go +++ b/tools/infra/infra.go @@ -25,13 +25,14 @@ func printLinks() { blue := color.New(color.FgBlue).SprintFunc() fmt.Printf("OpenIM Github: %s\n", blue("https://github.com/OpenIMSDK/Open-IM-Server")) fmt.Printf("Slack Invitation: %s\n", blue("https://openimsdk.slack.com")) + fmt.Printf("Follow Twitter: %s\n", blue("https://twitter.com/founder_im63606")) } func main() { yellow := color.New(color.FgYellow) blue := color.New(color.FgBlue, color.Bold) - yellow.Println("Current module is still under development.") + yellow.Println("Please use the release branch or tag for production environments!") message := ` ____ _____ __ __ From df793160879d9493c8a759f2a1c9b9355a83ebaf Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:02:41 +0800 Subject: [PATCH 36/90] Optimizing scripts --- scripts/install/openim-tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index a310bf54c..57de9772d 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -141,7 +141,7 @@ function openim::tools::pre-start() { function openim::tools::post-start() { #openim::log::info "Post-start actions for OpenIM Tools..." for tool in "${OPENIM_TOOLS_POST_START_NAME_LISTARIES[@]}"; do - openim::log::info "Starting tool: ${tool}" + openim::log::colorless "Starting tool: ${tool}" openim::tools::start_service ${tool} done } From 10e99188edf26b376fcfb6c11c58ace4ed576b48 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:06:54 +0800 Subject: [PATCH 37/90] Optimizing scripts --- scripts/make-rules/golang.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 5a5d1a788..c3fc727de 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -104,25 +104,25 @@ go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BIN ## go.start: Start openim .PHONY: go.start go.start: - @echo "===========> Starting openim" + @echo "===========> Starting OpenIM <===========" @$(ROOT_DIR)/scripts/start-all.sh ## go.stop: Stop openim .PHONY: go.stop go.stop: - @echo "===========> Stopping openim" + @echo "===========> Stopping OpenIM <===========" @$(ROOT_DIR)/scripts/stop-all.sh ## go.check: Check openim .PHONY: go.check go.check: - @echo "===========> Checking openim" + @echo "===========> Checking OpenIM <===========" @$(ROOT_DIR)/scripts/check-all.sh ## go.check-component: Check openim component .PHONY: go.check-component go.check-component: - @echo "===========> Checking openim component" + @echo "===========> Checking OpenIM component <===========" @$(ROOT_DIR)/scripts/install/openim-tools.sh openim::tools::pre-start ## go.versionchecker: Design, detect some environment variables and versions From 546de605a8c40fc103f3f7aa72431c17d6112b1b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:09:20 +0800 Subject: [PATCH 38/90] Optimizing scripts --- scripts/make-rules/golang.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index c3fc727de..506f8228e 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -104,25 +104,26 @@ go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BIN ## go.start: Start openim .PHONY: go.start go.start: - @echo "===========> Starting OpenIM <===========" + [2024-03-21 16:07:36 CST] Service component started successfully + @echo "=========================> Starting OpenIM <=========================" @$(ROOT_DIR)/scripts/start-all.sh ## go.stop: Stop openim .PHONY: go.stop go.stop: - @echo "===========> Stopping OpenIM <===========" + @echo "=========================> Stopping OpenIM <=========================" @$(ROOT_DIR)/scripts/stop-all.sh ## go.check: Check openim .PHONY: go.check go.check: - @echo "===========> Checking OpenIM <===========" + @echo "=========================> Checking OpenIM <=========================" @$(ROOT_DIR)/scripts/check-all.sh ## go.check-component: Check openim component .PHONY: go.check-component go.check-component: - @echo "===========> Checking OpenIM component <===========" + @echo "=========================> Checking OpenIM component <=========================" @$(ROOT_DIR)/scripts/install/openim-tools.sh openim::tools::pre-start ## go.versionchecker: Design, detect some environment variables and versions From 528ae3922f6e290ddcd33256430c0cabb1f4d204 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:10:32 +0800 Subject: [PATCH 39/90] Optimizing scripts --- scripts/make-rules/golang.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index 506f8228e..cfc3bf649 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -104,7 +104,6 @@ go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BIN ## go.start: Start openim .PHONY: go.start go.start: - [2024-03-21 16:07:36 CST] Service component started successfully @echo "=========================> Starting OpenIM <=========================" @$(ROOT_DIR)/scripts/start-all.sh From 02e6e1f76a012c91a787f6227a623372d9323ac6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:15:47 +0800 Subject: [PATCH 40/90] Optimizing scripts --- scripts/lib/golang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 54521cbc1..cc7629707 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -149,7 +149,7 @@ openim::golang::start_script_list() { openim-msgtransfer.sh openim-msggateway.sh openim-crontask.sh - openim-tools.sh + #openim-tools.sh ) local result=() for target in "${targets[@]}"; do From f0c6f5bb9f3f96c28fa8c30af689af8e7a576dde Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:18:22 +0800 Subject: [PATCH 41/90] Optimizing scripts --- scripts/start-all.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 1816cffb3..866edc065 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -106,23 +106,26 @@ fi openim::log::status "Start the OpenIM startup scripts: " execute_start_scripts +openim::log::colorless "OpenIM startup scripts have been successfully completed!" + sleep 2 result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then - openim::log::error "The program may fail to start.\n $result" + openim::log::error "The OpenIM services may fail to start.\n $result" exit 1 fi result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then - openim::log::error "The program may fail to start.\n $result" + openim::log::error "The OpenIM services may fail to start.\n $result" exit 1 fi openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start +openim::log::colorless "post-start has been successfully completed!" -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 211cb11d56a2c5b17fd7abde261568a3896a12f7 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:23:53 +0800 Subject: [PATCH 42/90] Optimizing scripts --- scripts/start-all.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 866edc065..88a1c4e6c 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -101,12 +101,9 @@ if [[ $? -ne 0 ]]; then exit 1 fi - - openim::log::status "Start the OpenIM startup scripts: " execute_start_scripts - -openim::log::colorless "OpenIM startup scripts have been successfully completed!" +openim::log::status "OpenIM startup scripts have been successfully completed!" sleep 2 @@ -126,6 +123,6 @@ fi openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::log::colorless "post-start has been successfully completed!" +openim::log::status "post-start has been successfully completed!" openim::log::success "All OpenIM services have been successfully started!" \ No newline at end of file From 5c51207305d837283b9a38281165398da0df9fb5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:28:51 +0800 Subject: [PATCH 43/90] Optimizing scripts --- scripts/check-all.sh | 8 +- scripts/demo.sh | 156 ------------------------------------ scripts/docker-start-all.sh | 2 +- 3 files changed, 5 insertions(+), 161 deletions(-) delete mode 100755 scripts/demo.sh diff --git a/scripts/check-all.sh b/scripts/check-all.sh index d41023384..cd30a319d 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -33,7 +33,7 @@ fi OPENIM_VERBOSE=4 -openim::log::info "\n# Begin to check all openim service" +openim::log::info "\n# Begin to check all OpenIM service" openim::log::status "Check all dependent service ports" # Elegant printing function @@ -65,9 +65,9 @@ print_services_and_ports "${OPENIM_SERVER_NAME_TARGETS[@]}" "${OPENIM_SERVER_POR print_services_and_ports "${OPENIM_DEPENDENCY_TARGETS[@]}" "${OPENIM_DEPENDENCY_PORT_TARGETS[@]}" # OpenIM check -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[@]}" +#echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}" +openim::log::info "\n## Check all dependent components service ports" +#echo "++ The port being checked: ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}" # Later, after discarding Docker, the Docker keyword is unreliable, and Kubepods is used diff --git a/scripts/demo.sh b/scripts/demo.sh deleted file mode 100755 index 4b877b9ed..000000000 --- a/scripts/demo.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env bash -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if ! command -v pv &> /dev/null -then - echo "pv not found, installing..." - if [ -e /etc/debian_version ]; then - sudo apt-get update - sudo apt-get install -y pv - elif [ -e /etc/redhat-release ]; then - sudo yum install -y pv - else - echo "Unsupported OS, please install pv manually." - exit 1 - fi -fi - -readonly t_reset=$(tput sgr0) -readonly green=$(tput bold; tput setaf 2) -readonly yellow=$(tput bold; tput setaf 3) -readonly blue=$(tput bold; tput setaf 6) -readonly timeout=$(if [ "$(uname)" == "Darwin" ]; then echo "1"; else echo "0.1"; fi) -readonly ipv6regex='(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' - -clear -. $(dirname ${BASH_SOURCE})/lib/util.sh - -openim::util::ensure-bash-version - -trap 'openim::util::onCtrlC' INT - -function openim::util::onCtrlC() { - echo -e "\n${t_reset}Ctrl+C Press it. It's exiting openim make init..." - exit 0 -} - -openim::util::desc "========> Welcome to the OpenIM Demo" -openim::util::desc "========> We'll help you get started with OpenIM quickly" -openim::util::desc "========> Press Enter to continue...." -openim::util::run "make advertise" -clear - -openim::util::desc "========> Initialize the project and generate configuration files" -openim::util::run "make init" -clear - -# openim::util::desc "========> You can look git diff" -# openim::util::run "git diff" -# clear - -openim::util::desc "You can learn a lot about automation using make help" -openim::util::run "make help" -clear - -openim::util::desc "You can learn a lot about automation using make help-all" -openim::util::run "make help-all" -clear - -openim::util::desc "First, let's verify and install some necessary tools" -openim::util::run "make tools" -clear - -openim::util::desc "========> Start the basic openim docker components" -openim::util::desc "========> You can use docker-compose ps to check the status of the container" -openim::util::run "docker compose up -d" -clear - -openim::util::desc "========> Use make init-githooks Initialize git hooks " -openim::util::run "make init-githooks" -clear - -openim::util::desc "The specification is pretty high, you need to be bound on your branch name, as well as commit messages" -openim::util::run "git commit -a -s -m 'feta: commit demo against specification'" -openim::util::run "# git commit -a -s -m 'feat: commit demo against specification' --amend" -clear - -openim::util::desc "How did we teach you how to build OpenIM" -openim::util::desc "A full build startup check" -openim::util::run "# make all" -openim::util::desc "Build one OpenIM binary" -openim::util::desc "BINS: openim-api openim-cmdutils openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc changelog infra ncpu yamlfmt" -openim::util::run "make build BINS=openim-api" -openim::util::run "make build" - -openim::util::desc "Build binaries for all platforms" -openim::util::run "make multiarch -j BINS=openim-crontask PLATFORMS='linux_arm64 linux_amd64' " - -openim::util::desc "If you wish to use dlv for debugging, either binary or process" -openim::util::desc "You need to enable debug mode" -openim::util::run "make build BINS=openim-cmdutils DEBUG=1" -clear - -openim::util::desc "Next, let's learn how to start the OpenIM service. For starting, we have two ways" -openim::util::desc "The first is Background startup" -openim::util::run "make start" -openim::util::desc "The second way is through the Linux system way" -openim::util::run "./scripts/install/install.sh --help" -clear - -openim::util::desc "Next, let's learn how to check the OpenIM service. For checking, we have two ways" -openim::util::run "make check" -clear - -openim::util::desc "Next, let's learn how to stop the OpenIM service. For stopping, we have two ways" -openim::util::run "make stop" -clear - -openim::util::desc "Run tidy to format and fix imports" -openim::util::run "make tidy" -clear - -openim::util::desc "Vendor go.mod dependencies" -openim::util::run "# make vendor" -clear - -openim::util::desc "Run unit tests" -openim::util::run "# make test" -clear - -openim::util::desc "Run unit tests and get test coverage" -openim::util::run "# make cover" -clear - -openim::util::desc "Check for updates to go.mod dependencies" -openim::util::run "# make updates" -clear - -openim::util::desc "You can learn a lot about automation using make clean, remove all files that are created by building" -openim::util::run "make clean" -clear - -openim::util::desc "Generate all necessary files" -openim::util::run "make gen" -clear - -openim::util::desc "Verify the license headers for all files" -openim::util::run "make verify-copyright" -clear - -openim::util::desc "Add copyright" -openim::util::run "make add-copyright" -clear - -exit 0 diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh index 4f8747a2a..8d91cd771 100755 --- a/scripts/docker-start-all.sh +++ b/scripts/docker-start-all.sh @@ -23,7 +23,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::info "\n# Use Docker to start all openim service" +openim::log::info "\n# Use Docker to start all OpenIM service" trap 'openim::util::onCtrlC' INT "${OPENIM_ROOT}"/scripts/start-all.sh 2>&1 & tail -f ${DOCKER_LOG_FILE} From e6df33bff11ff0383893fe933cd1ba512e8c06a8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:29:13 +0800 Subject: [PATCH 44/90] Optimizing scripts --- 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 cd30a319d..7e4216341 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -82,7 +82,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::log::success "All components depended on by openim are running normally! " + openim::log::success "All components depended on by OpenIM are running normally! " fi From dbb318d12518f9efd56468f1d8a20045ae142eba Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:31:37 +0800 Subject: [PATCH 45/90] Optimizing scripts --- 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 7e4216341..d5edefd30 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -74,7 +74,7 @@ openim::log::info "\n## Check all dependent components service ports" if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then openim::color::echo ${COLOR_CYAN} "Environment in the interior of the container" else - openim::color::echo ${COLOR_CYAN} "The environment is outside the container" + openim::color::echo ${COLOR_CYAN}"The environment is outside the container" openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} fi From 388155f4b388af1919d226d42c0be28e48817b96 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:40:47 +0800 Subject: [PATCH 46/90] Optimizing scripts --- scripts/check-all.sh | 6 +++--- scripts/lib/util.sh | 28 ++++++++++++++++++++++++++++ scripts/start-all.sh | 3 +++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index d5edefd30..3751f4f09 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -94,18 +94,18 @@ 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 result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then - echo "+++ cat openim log file >>> ${LOG_FILE}" + echo "+++ cat OpenIM log file >>> ${LOG_FILE}" openim::log::error "check process failed.\n " echo "$result" exit 1 else - openim::log::success "All openim services are running normally! " + openim::log::success "All OpenIM services are running normally! " fi diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 7bcfbad97..1341e12c9 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2847,6 +2847,34 @@ function openim::util::check_process_names_for_stop() { +function openim::util::find_process_ports() { + local process_path="$1" + if [[ -z "$process_path" ]]; then + echo "Usage: find_process_ports /path/to/process" + return 1 + fi + + + lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f $process_path)" | awk '{print $9, $8}' | while read line; do + local port_protocol=($line) + local port=${port_protocol[0]##*:} + local protocol=${port_protocol[1]} + echo "Process $process_path is listening on port $port with protocol $protocol" + done +} + +function openim::util::find_ports_for_all_services() { + local services=("$@") + for service in "${services[@]}"; do + find_process_ports "$service" + done +} + + + + + + if [[ "$*" =~ openim::util:: ]];then eval $* diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 88a1c4e6c..93badf639 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -120,6 +120,9 @@ if [[ $? -ne 0 ]]; then exit 1 fi +openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} + + openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start From 04d73382abcbc5e0a2eeee65b4da4a568fcae330 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:44:48 +0800 Subject: [PATCH 47/90] Optimizing scripts --- cmd/openim-api/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index 3a101f620..95bd744e9 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -16,12 +16,21 @@ package main import ( _ "net/http/pprof" + "time" "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil" ) +func panicAfterOneMinute() { + go func() { + <-time.After(1 * time.Minute) + panic("Panic after one minute!") + }() +} + func main() { + panicAfterOneMinute() apiCmd := cmd.NewApiCmd(cmd.ApiServer) apiCmd.AddPortFlag() apiCmd.AddPrometheusPortFlag() From 74aecef4126cd38aadb808b4240575b6454f8766 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:46:58 +0800 Subject: [PATCH 48/90] Optimizing scripts --- 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 1341e12c9..85ff15b67 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2866,7 +2866,7 @@ function openim::util::find_process_ports() { function openim::util::find_ports_for_all_services() { local services=("$@") for service in "${services[@]}"; do - find_process_ports "$service" + openim::util::find_process_ports "$service" done } From 67feff7102a90a99ea21fc7ec58ded86fbe9a828 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:49:02 +0800 Subject: [PATCH 49/90] Optimizing scripts --- cmd/openim-api/main.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index 95bd744e9..418218f1b 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -22,15 +22,11 @@ import ( util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil" ) -func panicAfterOneMinute() { +func main() { go func() { <-time.After(1 * time.Minute) panic("Panic after one minute!") }() -} - -func main() { - panicAfterOneMinute() apiCmd := cmd.NewApiCmd(cmd.ApiServer) apiCmd.AddPortFlag() apiCmd.AddPrometheusPortFlag() From 19a857fb515060b95eaecd8310e7fb8e5162745e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:50:11 +0800 Subject: [PATCH 50/90] Optimizing scripts --- scripts/check-all.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 3751f4f09..63b61ce1d 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -94,6 +94,7 @@ if [[ $? -ne 0 ]]; then fi + echo "Check OpenIM service name:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" @@ -109,3 +110,5 @@ else openim::log::success "All OpenIM services are running normally! " fi + +openim::util::find_process_ports ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} \ No newline at end of file From 8a24219a07fc251d6ff57abd65be85f4e60b5aaf Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:51:07 +0800 Subject: [PATCH 51/90] Optimizing scripts --- cmd/openim-api/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index 418218f1b..be52751af 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -24,7 +24,7 @@ import ( func main() { go func() { - <-time.After(1 * time.Minute) + time.Sleep(30 * time.Second) panic("Panic after one minute!") }() apiCmd := cmd.NewApiCmd(cmd.ApiServer) From ad635f85fb4889db36757045318fc5012c1e23d5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:55:53 +0800 Subject: [PATCH 52/90] Optimizing scripts --- scripts/check-all.sh | 3 ++- scripts/install/openim-api.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 63b61ce1d..02ca4a6f6 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -111,4 +111,5 @@ else fi -openim::util::find_process_ports ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} \ No newline at end of file +openim::util::find_process_ports ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} + diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index cd3d5eb08..0df844b12 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -89,7 +89,7 @@ function openim::api::start_service() { echo "Starting service with command: $cmd" #nohup $cmd >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >./tmp.log & if [ $? -ne 0 ]; then openim::log::error_exit "Failed to start ${binary_name} on port ${service_port}." return 1 From e5069079a8701ae177c8d15911eee2df9944ed22 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:58:38 +0800 Subject: [PATCH 53/90] Optimizing scripts --- 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 02ca4a6f6..803dad202 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -111,5 +111,5 @@ else fi -openim::util::find_process_ports ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} +openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} From 2b83bebf55b12bd0a724bb8001e10281b9aa1907 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 16:59:15 +0800 Subject: [PATCH 54/90] Optimizing scripts --- scripts/install/openim-api.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index 0df844b12..858a7af42 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -89,7 +89,7 @@ function openim::api::start_service() { echo "Starting service with command: $cmd" #nohup $cmd >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >./tmp.log & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >./tmp.log 2>&1 & if [ $? -ne 0 ]; then openim::log::error_exit "Failed to start ${binary_name} on port ${service_port}." return 1 From 975acb11b8536d59eb5a35f1ef376d148fa9fc57 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:10:17 +0800 Subject: [PATCH 55/90] Optimizing scripts --- scripts/install/openim-api.sh | 2 +- scripts/install/openim-crontask.sh | 2 +- scripts/install/openim-msggateway.sh | 2 +- scripts/install/openim-msgtransfer.sh | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index 858a7af42..8403382e6 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -89,7 +89,7 @@ function openim::api::start_service() { echo "Starting service with command: $cmd" #nohup $cmd >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) & - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >./tmp.log 2>&1 & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & if [ $? -ne 0 ]; then openim::log::error_exit "Failed to start ${binary_name} on port ${service_port}." return 1 diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh index 191701082..d785b37a4 100755 --- a/scripts/install/openim-crontask.sh +++ b/scripts/install/openim-crontask.sh @@ -53,7 +53,7 @@ function openim::crontask::start() { 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) & cmd="${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG}" - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & return 0 } diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index 25051aa6e..ed7910805 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -62,7 +62,7 @@ function openim::msggateway::start() { PROMETHEUS_PORT_OPTION="--prometheus_port ${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}" fi cmd="${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG}" - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & # 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 diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 23ce79c36..8daba12fc 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -58,7 +58,8 @@ function openim::msgtransfer::start() { PROMETHEUS_PORT_OPTION="--prometheus_port ${PROMETHEUS_MSG_TRANSFER_PORT}" fi cmd="${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i}" - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + #nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & #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 return 0 From 2d4f7bbe17c2b5b279c7ce4c6a3dc103c2b68091 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:12:09 +0800 Subject: [PATCH 56/90] Optimizing scripts --- scripts/install/openim-rpc.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index c3ac12449..1265a11c6 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -166,7 +166,8 @@ 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) & - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + #nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & return 0 } From b756959139f588fbed961974ee3b7d6cad00938d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:22:56 +0800 Subject: [PATCH 57/90] Optimizing scripts --- cmd/openim-api/main.go | 8 +------- scripts/check-all.sh | 3 ++- scripts/install/openim-push.sh | 3 ++- scripts/start-all.sh | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index be52751af..0f5b3a2dd 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -15,18 +15,12 @@ package main import ( - _ "net/http/pprof" - "time" - "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" util "github.com/openimsdk/open-im-server/v3/pkg/util/genutil" + _ "net/http/pprof" ) func main() { - go func() { - time.Sleep(30 * time.Second) - panic("Panic after one minute!") - }() apiCmd := cmd.NewApiCmd(cmd.ApiServer) apiCmd.AddPortFlag() apiCmd.AddPrometheusPortFlag() diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 803dad202..b7db44bdf 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -107,9 +107,10 @@ if [[ $? -ne 0 ]]; then echo "$result" exit 1 else + openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} openim::log::success "All OpenIM services are running normally! " fi -openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} + diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 8dea4b1f1..aafb24c7b 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -72,7 +72,8 @@ function openim::push::start() { for (( i=0; i<${#OPENIM_PUSH_PORTS_ARRAY[@]}; i++ )); do openim::log::info "start push process, port: ${OPENIM_PUSH_PORTS_ARRAY[$i]}, prometheus port: ${PUSH_PROM_PORTS_ARRAY[$i]}" cmd="${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]}" - nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + #nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null & + nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >> "${LOG_FILE}" 2>&1 & #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 diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 93badf639..76d0b3d3b 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -123,7 +123,6 @@ fi openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} - openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start openim::log::status "post-start has been successfully completed!" From c4e8b796ac086c76495ce80d7c4ba423b0c86374 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:27:55 +0800 Subject: [PATCH 58/90] Optimizing scripts --- scripts/lib/util.sh | 11 ++++++++++- scripts/start-all.sh | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 85ff15b67..c1b84b4f9 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2854,13 +2854,22 @@ function openim::util::find_process_ports() { return 1 fi + local ports_info="" lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f $process_path)" | awk '{print $9, $8}' | while read line; do local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} - echo "Process $process_path is listening on port $port with protocol $protocol" + ports_info+="$port($protocol) " done + + + if [[ -z "$ports_info" ]]; then + echo "No ports found for process $process_path." + else + + echo "Process $process_path is listening on ports: $ports_info" + fi } function openim::util::find_ports_for_all_services() { diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 76d0b3d3b..a7e4c8851 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -120,11 +120,11 @@ if [[ $? -ne 0 ]]; then exit 1 fi -openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} + openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start openim::log::status "post-start has been successfully completed!" - +openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} openim::log::success "All OpenIM services have been successfully started!" \ No newline at end of file From 90fd2fe84d42c5e80a0962df415cbee99fae03af Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:31:49 +0800 Subject: [PATCH 59/90] Optimizing scripts --- scripts/lib/util.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index c1b84b4f9..300fb42ed 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,7 +2846,6 @@ function openim::util::check_process_names_for_stop() { } - function openim::util::find_process_ports() { local process_path="$1" if [[ -z "$process_path" ]]; then @@ -2854,24 +2853,29 @@ function openim::util::find_process_ports() { return 1 fi + local pids=$(pgrep -f "$process_path") + if [[ -z "$pids" ]]; then + echo "No running process found for $process_path." + return 1 + fi + local ports_info="" - lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f $process_path)" | awk '{print $9, $8}' | while read line; do + while read -r line; do local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} ports_info+="$port($protocol) " - done - - - if [[ -z "$ports_info" ]]; then - echo "No ports found for process $process_path." - else + done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep -E "$(echo $pids | sed 's/ /\\|/g')") + if [[ -n "$ports_info" ]]; then echo "Process $process_path is listening on ports: $ports_info" + else + echo "No ports found for process $process_path." fi } + function openim::util::find_ports_for_all_services() { local services=("$@") for service in "${services[@]}"; do From 4f8d6d21b3b64ee950263fc29205ef259b8b13e2 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:36:11 +0800 Subject: [PATCH 60/90] Optimizing scripts --- scripts/lib/util.sh | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 300fb42ed..3d8d91f88 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,32 +2846,31 @@ function openim::util::check_process_names_for_stop() { } -function openim::util::find_process_ports() { +function openim::util::find_process_ports2() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" return 1 fi - local pids=$(pgrep -f "$process_path") - if [[ -z "$pids" ]]; then - echo "No running process found for $process_path." - return 1 - fi - local ports_info="" - - while read -r line; do + lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f $process_path)" | awk '{print $9, $8}' | while read line; do local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} - ports_info+="$port($protocol) " - done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep -E "$(echo $pids | sed 's/ /\\|/g')") + echo "Process $process_path is listening on port $port with protocol $protocol" + done +} + +function openim::util::find_process_ports() { + local process_path="$1" + + local ports=$(lsof -Fn -iTCP -iUDP | grep -i listen | grep "$process_path" | awk -F'[>:]' '{print $(NF-1) " " $NF}' | sort -u | tr '\n' ' ') - if [[ -n "$ports_info" ]]; then - echo "Process $process_path is listening on ports: $ports_info" + if [ -z "$ports" ]; then + echo "No listening ports found for the process." else - echo "No ports found for process $process_path." + echo "Listening on ports: $ports" fi } From c5e4b6a772b8265764a88609d59f2e55cb084052 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:37:15 +0800 Subject: [PATCH 61/90] Optimizing scripts --- scripts/lib/util.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 3d8d91f88..75fe06cd0 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,7 +2846,7 @@ function openim::util::check_process_names_for_stop() { } -function openim::util::find_process_ports2() { +function openim::util::find_process_ports() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" @@ -2862,17 +2862,6 @@ function openim::util::find_process_ports2() { done } -function openim::util::find_process_ports() { - local process_path="$1" - - local ports=$(lsof -Fn -iTCP -iUDP | grep -i listen | grep "$process_path" | awk -F'[>:]' '{print $(NF-1) " " $NF}' | sort -u | tr '\n' ' ') - - if [ -z "$ports" ]; then - echo "No listening ports found for the process." - else - echo "Listening on ports: $ports" - fi -} function openim::util::find_ports_for_all_services() { From b732b7468e07efd6bcd84cd32c81ad44726b6fed Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:46:02 +0800 Subject: [PATCH 62/90] Optimizing scripts --- scripts/lib/util.sh | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 75fe06cd0..22e5ef4a0 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,22 +2846,58 @@ function openim::util::check_process_names_for_stop() { } -function openim::util::find_process_ports() { +function openim::util::find_process_ports2() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" return 1 fi - + local protocol_ports="" lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f $process_path)" | awk '{print $9, $8}' | while read line; do local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} + protocol_ports= protocol_ports + $protocol + " "+$ports echo "Process $process_path is listening on port $port with protocol $protocol" done + + echo echo "Process $process_path is listening on protocol & port $protocol_ports " + } +function openim::util::find_process_ports() { + local process_path="$1" + if [[ -z "$process_path" ]]; then + echo "Usage: find_process_ports /path/to/process" + return 1 + fi + + local protocol_ports="" + local pids=$(pgrep -f "$process_path") + if [[ -z "$pids" ]]; then + echo "No process found for $process_path" + return 1 + fi + + lsof -nP -iTCP -iUDP | grep LISTEN | grep -E "$(echo $pids | sed 's/ /|/g')" | awk '{print $9, $8}' | while read -r port protocol; do + protocol_ports+="$protocol $port, " + echo "Process $process_path is listening on port ${port##*:} with protocol $protocol" + done + + + protocol_ports=${protocol_ports%, } + + if [[ -n "$protocol_ports" ]]; then + echo "Process $process_path is listening on protocol & port: $protocol_ports" + else + echo "Process $process_path is not listening on any port" + fi +} + + + + function openim::util::find_ports_for_all_services() { From 04c73efea70e44f5597e4d9b25880d12286ad1b4 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:47:52 +0800 Subject: [PATCH 63/90] Optimizing scripts --- 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 22e5ef4a0..18ea36226 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,7 +2846,7 @@ function openim::util::check_process_names_for_stop() { } -function openim::util::find_process_ports2() { +function openim::util::find_process_ports() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" @@ -2866,7 +2866,7 @@ function openim::util::find_process_ports2() { } -function openim::util::find_process_ports() { +function openim::util::find_process_ports2() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" From c5a681ecbd9d6d6f1b4b2f1e1d51dd06a8f02693 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:49:25 +0800 Subject: [PATCH 64/90] Optimizing scripts --- 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 18ea36226..f3cffd7c0 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2858,7 +2858,7 @@ function openim::util::find_process_ports() { local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} - protocol_ports= protocol_ports + $protocol + " "+$ports + protocol_ports=$protocol_ports+$protocol+" "+$ports echo "Process $process_path is listening on port $port with protocol $protocol" done From d2fc707f134e5bd05a775ff8a4b23bac3492ad82 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:51:07 +0800 Subject: [PATCH 65/90] Optimizing scripts --- 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 f3cffd7c0..a5d33cb9b 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2858,7 +2858,7 @@ function openim::util::find_process_ports() { local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} - protocol_ports=$protocol_ports+$protocol+" "+$ports + protocol_ports=$protocol_ports "" $protocol" "$port echo "Process $process_path is listening on port $port with protocol $protocol" done From e7da8d31fec8c8a8ee94cd0f8c5772a552280193 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:52:24 +0800 Subject: [PATCH 66/90] Optimizing scripts --- scripts/lib/util.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index a5d33cb9b..512db8c0f 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2858,10 +2858,11 @@ function openim::util::find_process_ports() { local port_protocol=($line) local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} - protocol_ports=$protocol_ports "" $protocol" "$port + protocol_ports="${protocol_ports}${protocol} ${port}, " echo "Process $process_path is listening on port $port with protocol $protocol" done + protocol_ports=${protocol_ports%, } echo echo "Process $process_path is listening on protocol & port $protocol_ports " } From 9a42d72239c68082c17bc1c46259cecd69d9483f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:54:30 +0800 Subject: [PATCH 67/90] Optimizing scripts --- scripts/lib/util.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 512db8c0f..cb99d9312 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2867,6 +2867,21 @@ function openim::util::find_process_ports() { } +function openim::util::find_process_ports3(){ + local protocol_ports="" + while read -r line; do + local port_protocol=($line) + local port=${port_protocol[0]##*:} + local protocol=${port_protocol[1]} + protocol_ports="${protocol_ports}${protocol} ${port}, " + echo "Process $process_path is listening on port $port with protocol $protocol" + done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}') + + protocol_ports=${protocol_ports%, } + echo "Process $process_path is listening on protocol & port $protocol_ports " + +} + function openim::util::find_process_ports2() { local process_path="$1" if [[ -z "$process_path" ]]; then From 9e231e9e4cec8805b3ecc570acdee04af6dc53ea Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 17:57:50 +0800 Subject: [PATCH 68/90] Optimizing scripts --- scripts/lib/util.sh | 48 +++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index cb99d9312..644565e82 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,7 +2846,7 @@ function openim::util::check_process_names_for_stop() { } -function openim::util::find_process_ports() { +function openim::util::find_process_ports1() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" @@ -2867,48 +2867,26 @@ function openim::util::find_process_ports() { } -function openim::util::find_process_ports3(){ - local protocol_ports="" - while read -r line; do - local port_protocol=($line) - local port=${port_protocol[0]##*:} - local protocol=${port_protocol[1]} - protocol_ports="${protocol_ports}${protocol} ${port}, " - echo "Process $process_path is listening on port $port with protocol $protocol" - done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}') - - protocol_ports=${protocol_ports%, } - echo "Process $process_path is listening on protocol & port $protocol_ports " - -} - -function openim::util::find_process_ports2() { +function openim::util::find_process_ports() { local process_path="$1" if [[ -z "$process_path" ]]; then echo "Usage: find_process_ports /path/to/process" return 1 fi - local protocol_ports="" - local pids=$(pgrep -f "$process_path") - if [[ -z "$pids" ]]; then - echo "No process found for $process_path" - return 1 - fi - - lsof -nP -iTCP -iUDP | grep LISTEN | grep -E "$(echo $pids | sed 's/ /|/g')" | awk '{print $9, $8}' | while read -r port protocol; do - protocol_ports+="$protocol $port, " - echo "Process $process_path is listening on port ${port##*:} with protocol $protocol" - done + local protocol_ports="" + while read -r line; do + local port_protocol=($line) + local port=${port_protocol[0]##*:} + local protocol=${port_protocol[1]} + protocol_ports="${protocol_ports}${protocol} ${port}, " + echo "Process $process_path is listening on port $port with protocol $protocol" + done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}') + protocol_ports=${protocol_ports%, } + echo "Process $process_path is listening on protocol & port $protocol_ports " - protocol_ports=${protocol_ports%, } - if [[ -n "$protocol_ports" ]]; then - echo "Process $process_path is listening on protocol & port: $protocol_ports" - else - echo "Process $process_path is not listening on any port" - fi } @@ -2916,6 +2894,8 @@ function openim::util::find_process_ports2() { + + function openim::util::find_ports_for_all_services() { local services=("$@") for service in "${services[@]}"; do From 905cda43bef61bfd6569ae37790f92c4e303c85b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:01:06 +0800 Subject: [PATCH 69/90] Optimizing scripts --- scripts/lib/util.sh | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 644565e82..89408a61b 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2846,26 +2846,7 @@ function openim::util::check_process_names_for_stop() { } -function openim::util::find_process_ports1() { - local process_path="$1" - if [[ -z "$process_path" ]]; then - echo "Usage: find_process_ports /path/to/process" - return 1 - fi - - local protocol_ports="" - lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f $process_path)" | awk '{print $9, $8}' | while read line; do - local port_protocol=($line) - local port=${port_protocol[0]##*:} - local protocol=${port_protocol[1]} - protocol_ports="${protocol_ports}${protocol} ${port}, " - echo "Process $process_path is listening on port $port with protocol $protocol" - done - - protocol_ports=${protocol_ports%, } - echo echo "Process $process_path is listening on protocol & port $protocol_ports " -} function openim::util::find_process_ports() { local process_path="$1" @@ -2880,12 +2861,11 @@ function openim::util::find_process_ports() { local port=${port_protocol[0]##*:} local protocol=${port_protocol[1]} protocol_ports="${protocol_ports}${protocol} ${port}, " - echo "Process $process_path is listening on port $port with protocol $protocol" + done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}') protocol_ports=${protocol_ports%, } - echo "Process $process_path is listening on protocol & port $protocol_ports " - + echo "Process $process_path is listening on protocol & port: $protocol_ports " } @@ -2893,9 +2873,6 @@ function openim::util::find_process_ports() { - - - function openim::util::find_ports_for_all_services() { local services=("$@") for service in "${services[@]}"; do @@ -2907,8 +2884,6 @@ function openim::util::find_ports_for_all_services() { - - if [[ "$*" =~ openim::util:: ]];then eval $* fi From 3b412a570813dd9d3ece86236e97391d6367a5e2 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:02:26 +0800 Subject: [PATCH 70/90] Optimizing scripts --- scripts/start-all.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index a7e4c8851..7caff49a6 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -43,7 +43,6 @@ function execute_start_scripts() { # Check if the script file exists and is executable. if [[ -x "$script_path" ]]; then openim::log::colorless "Starting script: ${script_path##*/}" # Log the script name. - # Execute the script with the constructed argument. result=$("$script_path" "$arg") if [[ $? -ne 0 ]]; then From 2e7adecff3999d351fc3444502c29e39cce90574 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:06:21 +0800 Subject: [PATCH 71/90] Optimizing scripts --- scripts/lib/util.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 89408a61b..05da8c385 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2865,8 +2865,12 @@ function openim::util::find_process_ports() { done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}') protocol_ports=${protocol_ports%, } - echo "Process $process_path is listening on protocol & port: $protocol_ports " + if [[ -z "$protocol_ports" ]]; then + echo "Process $process_path is not listening on any ports" + else + echo "Process $process_path is listening on protocol & port: $protocol_ports" + fi } From 64ac1ae03d76beda92704ea0e7fb5895ff971273 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:08:26 +0800 Subject: [PATCH 72/90] Optimizing scripts --- scripts/start-all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 7caff49a6..c446ec7b7 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -126,4 +126,6 @@ openim::log::status "Start the post-start tools:" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start openim::log::status "post-start has been successfully completed!" openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} +openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]} + openim::log::success "All OpenIM services have been successfully started!" \ No newline at end of file From e6d753a05028ab094763883799b850947f3d1005 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:11:30 +0800 Subject: [PATCH 73/90] Optimizing scripts --- scripts/check-all.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index b7db44bdf..2ec312c64 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -86,7 +86,7 @@ else fi -openim::log::info "\n## Check openim service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check openim service:\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}" @@ -95,7 +95,7 @@ fi -echo "Check OpenIM service name:" +echo "Check OpenIM service:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" done @@ -108,6 +108,7 @@ if [[ $? -ne 0 ]]; then exit 1 else openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} + openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]} openim::log::success "All OpenIM services are running normally! " fi From 720a64d55362a837bf5d3b2f519137264bd286c7 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:20:14 +0800 Subject: [PATCH 74/90] Optimizing scripts --- scripts/check-all.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 2ec312c64..a31eccaec 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -89,8 +89,9 @@ fi openim::log::info "\n## Check openim service:\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}" - openim::log::error "check process failed.\n $result" + #echo "+++ cat openim log file >>> ${LOG_FILE}" + + openim::log::error "The service is not running properly, please check the logs\n $result" fi @@ -103,7 +104,7 @@ 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 " + openim::log::error "The service is not running properly, please check the logs.\n " echo "$result" exit 1 else From e7de07a778922e114dbebf7ac38b8ed2f9f12ebc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:20:44 +0800 Subject: [PATCH 75/90] Optimizing scripts --- 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 a31eccaec..e05bdbdb9 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -103,7 +103,7 @@ done result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then - echo "+++ cat OpenIM log file >>> ${LOG_FILE}" + #echo "+++ cat OpenIM log file >>> ${LOG_FILE}" openim::log::error "The service is not running properly, please check the logs.\n " echo "$result" exit 1 From 2355f441e653c0db04001cbbd57e09b9387a6f18 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:24:49 +0800 Subject: [PATCH 76/90] Optimizing scripts --- scripts/lib/util.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 05da8c385..0be3b61a8 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 @@ -446,8 +446,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 From 9436a3bf95ef3c64c1f891f4d8fca740611c712f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:25:53 +0800 Subject: [PATCH 77/90] Optimizing scripts --- 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 e05bdbdb9..6fae15228 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -91,7 +91,7 @@ result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtr if [[ $? -ne 0 ]]; then #echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "The service is not running properly, please check the logs\n $result" + openim::log::error "The service is not running properly, please check the logs $result" fi @@ -104,7 +104,7 @@ 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 "The service is not running properly, please check the logs.\n " + openim::log::error "The service is not running properly, please check the logs " echo "$result" exit 1 else From 0b403a1e7fa2b457af5e688b6aeeb736bdf67636 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:28:32 +0800 Subject: [PATCH 78/90] Optimizing scripts --- 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 8daba12fc..8403d1cfc 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -83,7 +83,7 @@ function openim::msgtransfer::check() { fi done else - openim::log::error "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 running" return 1 fi return 0 From b4a5e6d07877d4ed9201f3ad0db3df424558b606 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:31:12 +0800 Subject: [PATCH 79/90] Optimizing scripts --- 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 6fae15228..5e51aee75 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -86,7 +86,7 @@ else fi -openim::log::info "\n## Check openim service:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::status "Check OpenIM service:\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}" @@ -96,7 +96,7 @@ fi -echo "Check OpenIM service:" +openim::log::status "Check OpenIM service:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" done From 3f9795c8614f7b0ee1adffbbdbeb87e55fcf98a5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:32:03 +0800 Subject: [PATCH 80/90] Optimizing scripts --- scripts/check-all.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 5e51aee75..dc9951b5e 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -95,8 +95,7 @@ if [[ $? -ne 0 ]]; then fi - -openim::log::status "Check OpenIM service:" +openim::log::info "Check OpenIM service:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" done From a33dca049ec8db23d4688c9b9e55bdcea9a4d282 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:34:02 +0800 Subject: [PATCH 81/90] Optimizing scripts --- scripts/check-all.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index dc9951b5e..a5a52c49a 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -86,7 +86,8 @@ else fi -openim::log::status "Check OpenIM service:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::status "Check OpenIM service:" +openim::log::colorless ${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}" @@ -95,9 +96,9 @@ if [[ $? -ne 0 ]]; then fi -openim::log::info "Check OpenIM service:" +openim::log::status "Check OpenIM service:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do - echo "$item" + openim::log::colorless "$item" done result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) From 789457433cbf70e88ff702cedefda6ecdbe1fdfc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:34:48 +0800 Subject: [PATCH 82/90] Optimizing scripts --- 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 a5a52c49a..52da05ef3 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -87,7 +87,7 @@ fi openim::log::status "Check OpenIM service:" -openim::log::colorless ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::colorless "${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 86c9a51faf6eab56cc247b1ef4a68d2b4b1a0346 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:36:02 +0800 Subject: [PATCH 83/90] Optimizing scripts --- scripts/check-all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 52da05ef3..0c3d1edbe 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -101,6 +101,8 @@ for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do openim::log::colorless "$item" done +openim::log::status "List the ports listened to by the OpenIM service:" + result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then #echo "+++ cat OpenIM log file >>> ${LOG_FILE}" From 4d53925a502ecc68a79c4bbf61fd599efbf5a85a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:38:23 +0800 Subject: [PATCH 84/90] Optimizing scripts --- 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 0be3b61a8..5a5de4003 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2867,9 +2867,9 @@ function openim::util::find_process_ports() { protocol_ports=${protocol_ports%, } if [[ -z "$protocol_ports" ]]; then - echo "Process $process_path is not listening on any ports" + openim::log::colorless "$process_path is not listening on any ports" else - echo "Process $process_path is listening on protocol & port: $protocol_ports" + openim::log::colorless "$process_path is listening on protocol & port: $protocol_ports" fi } From df328287121f627762c4f3a90f781302a6f6300f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:45:23 +0800 Subject: [PATCH 85/90] Optimizing scripts --- scripts/check-all.sh | 2 +- scripts/lib/util.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 0c3d1edbe..2fc773b2f 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -101,7 +101,6 @@ for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do openim::log::colorless "$item" done -openim::log::status "List the ports listened to by the OpenIM service:" result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then @@ -110,6 +109,7 @@ if [[ $? -ne 0 ]]; then echo "$result" exit 1 else + openim::log::status "List the ports listened to by the OpenIM service:" openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]} openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]} openim::log::success "All OpenIM services are running normally! " diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 5a5de4003..6bb330981 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -603,6 +603,7 @@ openim::util::stop_services_with_name() { # 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. + echo "Stopping services with names: $server_name" local pids=$(pgrep -f "$server_name") # If no process was found with the name, add it to the not_stopped list From 036e00eff0707b1291d504f11979f2dfd16fcf0f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:46:30 +0800 Subject: [PATCH 86/90] Optimizing scripts --- 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 6bb330981..117e46c08 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -603,7 +603,7 @@ openim::util::stop_services_with_name() { # 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. - echo "Stopping services with names: $server_name" + echo "Stopping services with name: $server_name" local pids=$(pgrep -f "$server_name") # If no process was found with the name, add it to the not_stopped list From 753ba6f08f533facdbc7476e6b1eeafddce97071 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:47:29 +0800 Subject: [PATCH 87/90] Optimizing scripts --- scripts/lib/util.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 117e46c08..9588f727d 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -605,6 +605,7 @@ openim::util::stop_services_with_name() { # Use the `pgrep` command to find process IDs related to the given service name. echo "Stopping services with name: $server_name" local pids=$(pgrep -f "$server_name") + echo "Stopping services with name: $server_name "$pids # If no process was found with the name, add it to the not_stopped list if [[ -z $pids ]]; then From 8c8a0232d9fa3cd48451a6e9120b3f04ed9179fe Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:50:21 +0800 Subject: [PATCH 88/90] Optimizing scripts --- scripts/lib/util.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 9588f727d..92f809e73 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -613,21 +613,26 @@ openim::util::stop_services_with_name() { continue fi local stopped_this_time=false - for pid in $pids; do + for pid in $pids; do - # Exclude the PID of the current script - if [[ "$pid" == "$$" ]]; then - continue - fi + # Exclude the PID of the current script + if [[ "$pid" == "$$" ]]; then + continue + fi + + # If there's a Process ID, it means the service with the name is running. + if [[ -n $pid ]]; then + # Print the binary path for the PID + binary_path=$(readlink -f /proc/$pid/exe) + echo "PID $pid corresponds to binary path: $binary_path" + + # Try to stop the service by killing its process. + if kill -15 $pid 2>/dev/null; then + stopped_this_time=true + fi + fi + done - # If there's a Process ID, it means the service with the name is running. - if [[ -n $pid ]]; then - # Try to stop the service by killing its process. - if kill -15 $pid 2>/dev/null; then - stopped_this_time=true - fi - fi - done if $stopped_this_time; then stopped+=("$server_name") From 52034e2db05b24893c1f53af6df7e3b1c492bca1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:51:55 +0800 Subject: [PATCH 89/90] Optimizing scripts --- scripts/lib/util.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 92f809e73..02f2f8bc3 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -599,11 +599,9 @@ openim::util::stop_services_with_name() { # An array to collect information about processes that were stopped. local stopped=() - echo "Stopping services with names: $*" # Iterate over each given service name. for server_name in "$@"; do # Use the `pgrep` command to find process IDs related to the given service name. - echo "Stopping services with name: $server_name" local pids=$(pgrep -f "$server_name") echo "Stopping services with name: $server_name "$pids @@ -624,7 +622,7 @@ openim::util::stop_services_with_name() { if [[ -n $pid ]]; then # Print the binary path for the PID binary_path=$(readlink -f /proc/$pid/exe) - echo "PID $pid corresponds to binary path: $binary_path" + openim::log::colorless "stop PID $pid path: $binary_path" # Try to stop the service by killing its process. if kill -15 $pid 2>/dev/null; then From 370f4422590ebae501603ea8191094f794bf74b1 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 21 Mar 2024 18:53:07 +0800 Subject: [PATCH 90/90] Optimizing scripts --- scripts/lib/util.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 02f2f8bc3..db0d4226b 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -603,8 +603,6 @@ openim::util::stop_services_with_name() { for server_name in "$@"; do # Use the `pgrep` command to find process IDs related to the given service name. local pids=$(pgrep -f "$server_name") - echo "Stopping services with name: $server_name "$pids - # If no process was found with the name, add it to the not_stopped list if [[ -z $pids ]]; then not_stopped+=("$server_name") @@ -622,7 +620,7 @@ openim::util::stop_services_with_name() { if [[ -n $pid ]]; then # Print the binary path for the PID binary_path=$(readlink -f /proc/$pid/exe) - openim::log::colorless "stop PID $pid path: $binary_path" + openim::log::colorless "stop PID $pid full path: $binary_path" # Try to stop the service by killing its process. if kill -15 $pid 2>/dev/null; then