Optimize script logs

pull/2007/head^2
skiffer-git 2 years ago
parent ff3b8d1d57
commit 14bce90f14

@ -402,8 +402,8 @@ openim::util::check_process_names() {
local not_started=() local not_started=()
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))
@ -415,7 +415,7 @@ openim::util::check_process_names() {
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) local port=$(get_port $pid | tr -d '\n') # Use `tr` to remove newline characters
# Check if port information was found for the PID # Check if port information was found for the PID
if [[ -z $port ]]; then if [[ -z $port ]]; then
@ -425,7 +425,8 @@ openim::util::check_process_names() {
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time") started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")
done done
fi fi
done done
# Print information # Print information
if [[ ${#not_started[@]} -ne 0 ]]; then if [[ ${#not_started[@]} -ne 0 ]]; then

@ -95,7 +95,6 @@ sleep 2
result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check)
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "The program may fail to start.\n $result" openim::log::error "The program may fail to start.\n $result"
exit 1 exit 1
fi fi
@ -103,7 +102,6 @@ fi
result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]})
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "The program may fail to start.\n $result" openim::log::error "The program may fail to start.\n $result"
exit 1 exit 1
fi fi

Loading…
Cancel
Save