mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-02 18:34:29 +08:00
Optimize script logs
This commit is contained in:
parent
422c01870a
commit
74802c601c
@ -401,33 +401,36 @@ openim::util::check_process_names() {
|
|||||||
# Arrays to collect details of processes
|
# Arrays to collect details of processes
|
||||||
local not_started=()
|
local not_started=()
|
||||||
local started=()
|
local started=()
|
||||||
|
|
||||||
# Iterate over each given process name
|
|
||||||
for process_name in "$@"; do
|
|
||||||
# Use `pgrep` to find process IDs related to the given process name
|
|
||||||
local pids=($(pgrep -f $process_name))
|
|
||||||
|
|
||||||
# Check if any process IDs were found
|
# Iterate over each given process name
|
||||||
if [[ ${#pids[@]} -eq 0 ]]; then
|
for process_name in "$@"; do
|
||||||
not_started+=("$process_name")
|
# Use `pgrep` to find process IDs related to the given process name
|
||||||
else
|
local pids=($(pgrep -f $process_name))
|
||||||
# If there are PIDs, loop through each one
|
|
||||||
for pid in "${pids[@]}"; do
|
|
||||||
local command=$(ps -p $pid -o cmd=)
|
|
||||||
local start_time=$(ps -p $pid -o lstart=)
|
|
||||||
local port=$(get_port $pid | tr -d '\n') # Remove newline characters
|
|
||||||
|
|
||||||
# Ensure port information is followed by a space for separation
|
# Check if any process IDs were found
|
||||||
if [[ -z $port ]]; then
|
if [[ ${#pids[@]} -eq 0 ]]; then
|
||||||
port="N/A "
|
not_started+=("$process_name")
|
||||||
else
|
else
|
||||||
port="$port " # Add a trailing space for separation
|
# If there are PIDs, loop through each one
|
||||||
fi
|
for pid in "${pids[@]}"; do
|
||||||
|
local command=$(ps -p $pid -o cmd=)
|
||||||
|
local start_time=$(ps -p $pid -o lstart=)
|
||||||
|
local port=$(get_port $pid | tr -d '\n') # Remove newline characters
|
||||||
|
|
||||||
|
# Insert a space at the desired position in the port string
|
||||||
|
if [[ ! -z $port && $port != "N/A" ]]; then
|
||||||
|
port="${port:0:4} ${port:4}" # Add a space after the fourth character
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $port ]]; then
|
||||||
|
port="N/A"
|
||||||
|
fi
|
||||||
|
|
||||||
|
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
# Print information
|
# Print information
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user