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
406228297e
commit
b85bb4ca4b
@ -403,34 +403,29 @@ openim::util::check_process_names() {
|
|||||||
local started=()
|
local started=()
|
||||||
|
|
||||||
# Iterate over each given process name
|
# Iterate over each given process name
|
||||||
for process_name in "$@"; do
|
for process_name in "$@"; do
|
||||||
# Use `pgrep` to find process IDs related to the given process name
|
# Use `pgrep` to find process IDs related to the given process name
|
||||||
local pids=($(pgrep -f $process_name))
|
local pids=($(pgrep -f $process_name))
|
||||||
|
|
||||||
# Check if any process IDs were found
|
# Check if any process IDs were found
|
||||||
if [[ ${#pids[@]} -eq 0 ]]; then
|
if [[ ${#pids[@]} -eq 0 ]]; then
|
||||||
not_started+=("$process_name")
|
not_started+=($process_name)
|
||||||
else
|
else
|
||||||
# If there are PIDs, loop through each one
|
# If there are PIDs, loop through each one
|
||||||
for pid in "${pids[@]}"; do
|
for pid in "${pids[@]}"; do
|
||||||
local command=$(ps -p $pid -o cmd=)
|
local command=$(ps -p $pid -o cmd=)
|
||||||
local start_time=$(ps -p $pid -o lstart=)
|
local start_time=$(ps -p $pid -o lstart=)
|
||||||
local port=$(get_port $pid | tr -d '\n') # Remove any newline characters
|
local port=$(get_port $pid)
|
||||||
|
|
||||||
# Add space within port numbers, assuming you need to format them
|
# Check if port information was found for the PID
|
||||||
if [[ ! -z $port && $port != "N/A" ]]; then
|
if [[ -z $port ]]; then
|
||||||
# Example formatting: assuming ports are returned as a single long string and you want to separate every 4 characters with a space
|
port="N/A"
|
||||||
port=$(echo "$port" | sed 's/.\{4\}/& /g')
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $port ]]; then
|
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")
|
||||||
port="N/A"
|
done
|
||||||
fi
|
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