From d417645d4892c4acb83c7349f91ce1e9337da2e5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 2 Apr 2024 17:20:34 +0800 Subject: [PATCH] Script Refactoring --- scripts-new/bricks.sh | 2 -- scripts-new/lib/logging.sh | 5 +++++ scripts-new/stop.sh | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index b8f352d3f..d6ea44f12 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -56,10 +56,8 @@ check_binaries_stop() { done if [ "$running_binaries" -ne 0 ]; then - echo "There are $running_binaries binaries still running. Aborting..." return 1 else - echo "All processes have been stopped." return 0 fi } diff --git a/scripts-new/lib/logging.sh b/scripts-new/lib/logging.sh index ffde53d85..b2cf8e307 100644 --- a/scripts-new/lib/logging.sh +++ b/scripts-new/lib/logging.sh @@ -284,6 +284,11 @@ function openim::log::print_red() { echo -e "[$current_time] \033[0;31m$1\033[0m" } +function openim::log::print_red_two_lines() { + local current_time=$(date "+%Y-%m-%d %H:%M:%S %Z") + echo -e "[$current_time]" + echo -e "\033[0;31m$1\033[0m" +} diff --git a/scripts-new/stop.sh b/scripts-new/stop.sh index 2ea534525..9772b3cd0 100644 --- a/scripts-new/stop.sh +++ b/scripts-new/stop.sh @@ -14,11 +14,10 @@ kill_exist_binaries result=$(check_binaries_stop) ret_val=$? - if [ $ret_val -ne 0 ]; then - echo "$result" - echo "no stop..." + openim::log::print_red "Some services have not been stopped, details are as follows:" + openim::log::print_red_two_lines "$result" exit 1 fi -echo "all stop" \ No newline at end of file +openim::log::print_green "All services have been stopped" \ No newline at end of file