From 1a6d500155b71c5df2124c3d6e2a888486d5ebea Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 15:40:33 +0800 Subject: [PATCH] fix: fix the error output --- scripts/install/openim-msgtransfer.sh | 26 -------------------------- scripts/lib/util.sh | 13 ++++++------- scripts/stop-all.sh | 2 +- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 48218dc41..fb5b55622 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -87,32 +87,6 @@ function openim::msgtransfer::check() { fi } -function openim::msgtransfer::check_by_signal() { - PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") || PIDS="0" - if [ "$PIDS" = "0" ]; then - return 0 - fi - - NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) - - if [ "$NUM_PROCESSES" -gt 0 ]; then - openim::log::error "Found $NUM_PROCESSES processes for $OPENIM_OUTPUT_HOSTBIN/openim-msgtransfer" - for PID in $PIDS; do - if [[ "$OSTYPE" == "linux-gnu"* ]]; then - echo -e "\033[31m$(ps -p $PID -o pid,cmd)\033[0m" - elif [[ "$OSTYPE" == "darwin"* ]]; then - echo -e "\033[31m$(ps -p $PID -o pid,comm)\033[0m" - else - openim::log::error "Unsupported OS type: $OSTYPE" - fi - done - openim::log::error "Processes have not been stopped properly." - else - openim::log::success "All openim-msgtransfer processes have been stopped properly." - fi - return 0 -} - ###################################### Linux Systemd ###################################### SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 6cc6e2211..bd1cb32b3 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -726,19 +726,18 @@ openim::util::stop_services_with_name() { elapsed_time=$(($SECONDS - $start_time)) if [[ $elapsed_time -ge $timeout ]]; then echo "Timeout of ${timeout} seconds reached." + openim::log::info "# Begin to check all openim service" + openim::util::check_by_signal + + + echo "Check ports:" + openim::util::check_ports_by_signal ${OPENIM_SERVER_PORT_LISTARIES[@]} break # Timeout, exit while loop fi sleep 1 done - openim::log::info "# Begin to check all openim service" - openim::util::check_by_signal - - - echo "Check ports:" - openim::util::check_ports_by_signal ${OPENIM_SERVER_PORT_LISTARIES[@]} - # Print information about services whose processes couldn't be stopped. if [[ ${#not_stopped[@]} -ne 0 ]]; then diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 794aea66b..144e4db72 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -37,7 +37,7 @@ openim::util::stop_services_by_name_signal "${OPENIM_OUTPUT_HOSTBIN}" sleep 1 openim::log::info "# Begin to check all openim service" -openim::msgtransfer::check_by_signal +openim::util::check_by_signal echo "Check ports:"