mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-02 18:34:29 +08:00
fix: fix the transfer output
This commit is contained in:
parent
6aec72a5a4
commit
83ee01acfd
@ -48,5 +48,5 @@ func ExitWithError(err error) {
|
||||
|
||||
func SIGTERMExit() {
|
||||
progName := filepath.Base(os.Args[0])
|
||||
fmt.Printf("%s receive process terminal SIGTERM exit 0", progName)
|
||||
fmt.Fprintf(os.Stderr, "Warning %s receive process terminal SIGTERM exit 0", progName)
|
||||
}
|
||||
|
||||
@ -42,10 +42,9 @@ trap handle_error ERR
|
||||
|
||||
openim::util::check_ports_by_signal ${OPENIM_SERVER_PORT_LISTARIES[@]}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
openim::log::success "++++ All openim service ports stop successfully !"
|
||||
else
|
||||
echo "+++ cat openim log file >>> ${LOG_FILE}"
|
||||
openim::log::error "The service does not stop properly, there are still processes running, please check!"
|
||||
else
|
||||
openim::log::success "++++ All openim service ports stop successfully !"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ function openim::api::start_service() {
|
||||
echo "Starting service with command: $cmd"
|
||||
|
||||
nohup $cmd >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
|
||||
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
openim::log::error_exit "Failed to start ${binary_name} on port ${service_port}."
|
||||
|
||||
@ -23,7 +23,6 @@ set -o pipefail
|
||||
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
|
||||
|
||||
openim::util::set_max_fd 200000
|
||||
|
||||
SERVER_NAME="openim-msgtransfer"
|
||||
|
||||
@ -93,7 +92,7 @@ function openim::msgtransfer::check_by_signal() {
|
||||
NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs)
|
||||
|
||||
if [ "$NUM_PROCESSES" -gt 0 ]; then
|
||||
openim::log::info "Found $NUM_PROCESSES processes for $OPENIM_OUTPUT_HOSTBIN/openim-msgtransfer"
|
||||
openim::log::error "Found $NUM_PROCESSES processes for $OPENIM_OUTPUT_HOSTBIN/openim-msgtransfer"
|
||||
for PID in $PIDS; do
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
ps -p $PID -o pid,cmd
|
||||
@ -109,6 +108,39 @@ function openim::msgtransfer::check_by_signal() {
|
||||
fi
|
||||
}
|
||||
|
||||
function openim::msgtransfer::check_by_signal() {
|
||||
PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer")
|
||||
if [ -z "$PIDS" ]; then
|
||||
openim::log::success "All openim-msgtransfer processes have been stopped properly."
|
||||
return 0
|
||||
fi
|
||||
|
||||
openim::log::error "Found processes for $OPENIM_OUTPUT_HOSTBIN/openim-msgtransfer:"
|
||||
for PID in $PIDS; do
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Extract details for Linux
|
||||
details=$(ps -p $PID -o pid,comm,lstart= | awk 'NR>1 {print $1, $2, $3, $4, $5, $6, $7}')
|
||||
command=$(echo $details | awk '{print $2}')
|
||||
start_time=$(echo $details | awk '{print $3, $4, $5, $6, $7}')
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# Handle details extraction for macOS
|
||||
details=$(ps -p $PID -o pid,comm,start= | awk 'NR>1 {print $1, $2, $3}')
|
||||
command=$(echo $details | awk '{print $2}')
|
||||
start_time=$(echo $details | awk '{print $3}')
|
||||
else
|
||||
openim::log::error "Unsupported OS type: $OSTYPE"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Assuming FD and port number are not directly retrievable for msgtransfer processes
|
||||
openim::log::error "PID: $PID - Command: $command, Started: $start_time"
|
||||
done
|
||||
|
||||
openim::log::success "Processes have not been stopped properly."
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
function openim::msgtransfer::check_by_signal1() {
|
||||
PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer")
|
||||
|
||||
|
||||
@ -378,7 +378,6 @@ openim::util::check_ports_by_signal() {
|
||||
# An array to collect information about processes that are running.
|
||||
local started=()
|
||||
|
||||
openim::log::info "Checking ports: $*"
|
||||
# Iterate over each given port.
|
||||
for port in "$@"; do
|
||||
# Initialize variables
|
||||
@ -432,22 +431,21 @@ openim::util::check_ports_by_signal() {
|
||||
|
||||
# Print information about ports whose processes are running.
|
||||
if [[ ${#started[@]} -ne 0 ]]; then
|
||||
openim::log::info "\n### No stop ports:"
|
||||
openim::log::error "\n### No stop ports:"
|
||||
for info in "${started[@]}"; do
|
||||
openim::log::info "$info"
|
||||
openim::log::error "$info"
|
||||
done
|
||||
fi
|
||||
|
||||
# If any of the processes is not running, return a status of 1.
|
||||
if [[ ${#not_started[@]} -ne 0 ]]; then
|
||||
openim::log::success "All specified processes are running."
|
||||
return 1
|
||||
return 0
|
||||
else
|
||||
openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}'
|
||||
openim::log::error "Have processes no stop."
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user