mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
Optimizing scripts
This commit is contained in:
parent
9a42d72239
commit
9e231e9e4c
@ -2846,7 +2846,7 @@ function openim::util::check_process_names_for_stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openim::util::find_process_ports() {
|
function openim::util::find_process_ports1() {
|
||||||
local process_path="$1"
|
local process_path="$1"
|
||||||
if [[ -z "$process_path" ]]; then
|
if [[ -z "$process_path" ]]; then
|
||||||
echo "Usage: find_process_ports /path/to/process"
|
echo "Usage: find_process_ports /path/to/process"
|
||||||
@ -2867,48 +2867,26 @@ function openim::util::find_process_ports() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openim::util::find_process_ports3(){
|
function openim::util::find_process_ports() {
|
||||||
local protocol_ports=""
|
|
||||||
while read -r line; do
|
|
||||||
local port_protocol=($line)
|
|
||||||
local port=${port_protocol[0]##*:}
|
|
||||||
local protocol=${port_protocol[1]}
|
|
||||||
protocol_ports="${protocol_ports}${protocol} ${port}, "
|
|
||||||
echo "Process $process_path is listening on port $port with protocol $protocol"
|
|
||||||
done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}')
|
|
||||||
|
|
||||||
protocol_ports=${protocol_ports%, }
|
|
||||||
echo "Process $process_path is listening on protocol & port $protocol_ports "
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function openim::util::find_process_ports2() {
|
|
||||||
local process_path="$1"
|
local process_path="$1"
|
||||||
if [[ -z "$process_path" ]]; then
|
if [[ -z "$process_path" ]]; then
|
||||||
echo "Usage: find_process_ports /path/to/process"
|
echo "Usage: find_process_ports /path/to/process"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local protocol_ports=""
|
local protocol_ports=""
|
||||||
local pids=$(pgrep -f "$process_path")
|
while read -r line; do
|
||||||
if [[ -z "$pids" ]]; then
|
local port_protocol=($line)
|
||||||
echo "No process found for $process_path"
|
local port=${port_protocol[0]##*:}
|
||||||
return 1
|
local protocol=${port_protocol[1]}
|
||||||
fi
|
protocol_ports="${protocol_ports}${protocol} ${port}, "
|
||||||
|
echo "Process $process_path is listening on port $port with protocol $protocol"
|
||||||
|
done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}')
|
||||||
|
|
||||||
lsof -nP -iTCP -iUDP | grep LISTEN | grep -E "$(echo $pids | sed 's/ /|/g')" | awk '{print $9, $8}' | while read -r port protocol; do
|
protocol_ports=${protocol_ports%, }
|
||||||
protocol_ports+="$protocol $port, "
|
echo "Process $process_path is listening on protocol & port $protocol_ports "
|
||||||
echo "Process $process_path is listening on port ${port##*:} with protocol $protocol"
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
protocol_ports=${protocol_ports%, }
|
|
||||||
|
|
||||||
if [[ -n "$protocol_ports" ]]; then
|
|
||||||
echo "Process $process_path is listening on protocol & port: $protocol_ports"
|
|
||||||
else
|
|
||||||
echo "Process $process_path is not listening on any port"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2916,6 +2894,8 @@ function openim::util::find_process_ports2() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function openim::util::find_ports_for_all_services() {
|
function openim::util::find_ports_for_all_services() {
|
||||||
local services=("$@")
|
local services=("$@")
|
||||||
for service in "${services[@]}"; do
|
for service in "${services[@]}"; do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user