mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
Optimize script logs
This commit is contained in:
parent
74802c601c
commit
ae75708e92
@ -402,34 +402,36 @@ openim::util::check_process_names() {
|
||||
local not_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))
|
||||
# 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
|
||||
if [[ ${#pids[@]} -eq 0 ]]; then
|
||||
not_started+=("$process_name")
|
||||
else
|
||||
# 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
|
||||
# Check if any process IDs were found
|
||||
if [[ ${#pids[@]} -eq 0 ]]; then
|
||||
not_started+=("$process_name")
|
||||
else
|
||||
# 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 any 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
|
||||
# Add space within port numbers, assuming you need to format them
|
||||
if [[ ! -z $port && $port != "N/A" ]]; then
|
||||
# Example formatting: assuming ports are returned as a single long string and you want to separate every 4 characters with a space
|
||||
port=$(echo "$port" | sed 's/.\{4\}/& /g')
|
||||
fi
|
||||
|
||||
if [[ -z $port ]]; then
|
||||
port="N/A"
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user