Script Refactoring

pull/2148/head
skiffer-git 2 years ago
parent 4436d388b3
commit aa151878f9

@ -2455,8 +2455,6 @@ function openim::util::print_binary_ports() {
# Check if the binary is running
if pgrep -f "$binary_path" > /dev/null; then
# echo "$binary_name is running." "arg $1"
# Find the PID(s) of the running binary
pids=$(pgrep -f "$binary_path")
@ -2468,11 +2466,9 @@ function openim::util::print_binary_ports() {
# Check for listening ports using lsof
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
# Append found ports to the ports variable, followed by a space
ports+=$(lsof -i -n | grep LISTEN | grep "$pid" | awk '{print $9}' | cut -d':' -f2 | uniq | tr '\n' ' ')
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
# Append found ports to the ports variable, followed by a space
ports+=$(lsof -i -n | grep LISTEN | grep "$pid" | awk '{print $9}' | awk -F'[:\.]+' '{print $(NF-1)}' | uniq | tr '\n' ' ')
fi
done
@ -2492,6 +2488,7 @@ function openim::util::print_binary_ports() {
function openim::util::kill_exist_binary() {
local binary_path="$1"
local pids=$(pgrep -f "$binary_path")

Loading…
Cancel
Save