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