From 406228297e733d48300419d72a1831420edee8b3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 6 Mar 2024 15:44:00 +0800 Subject: [PATCH] Optimize script logs --- 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 f647284be..4ca796beb 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -384,20 +384,19 @@ openim::util::check_ports() { # The function returns a status of 1 if any of the processes is not running. openim::util::check_process_names() { # Function to get the port of a process - get_port() { - local pid=$1 - if [[ "$OSTYPE" == "linux-gnu"* ]]; then - # Linux - ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2 | tr '\n' ' ' - elif [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - lsof -nP -iTCP -sTCP:LISTEN -a -p $pid | awk 'NR>1 {print $9}' | sed 's/.*://' | tr '\n' ' ' - else - echo "Unsupported OS" - return 1 - fi - } - + get_port() { + local pid=$1 + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Linux + ss -ltnp 2>/dev/null | grep $pid | awk '{print $4}' | cut -d ':' -f2 + elif [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + lsof -nP -iTCP -sTCP:LISTEN -a -p $pid | awk 'NR>1 {print $9}' | sed 's/.*://' + else + echo "Unsupported OS" + return 1 + fi + } # Arrays to collect details of processes local not_started=()