Optimize logs (#2007)

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* fix: wrap the error of group user and thrid (#2005)

* fix: wrap the error of group user and thrid

* fix: del the chinese comment

* fix: fix the make_lint error

* fix: fix the ApiTest error

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

* Optimize script logs

---------

Co-authored-by: Brabem <69128477+luhaoling@users.noreply.github.com>
pull/2009/head
skiffer-git 9 months ago committed by GitHub
parent 52b8efba73
commit c79f46f8a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -88,8 +88,8 @@ 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) &
#nohup $cmd >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
if [ $? -ne 0 ]; then
openim::log::error_exit "Failed to start ${binary_name} on port ${service_port}."
return 1

@ -51,8 +51,9 @@ function openim::crontask::start() {
openim::log::status "Start OpenIM Cron, path: ${OPENIM_CRONTASK_BINARY}"
openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}"
nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
#nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
cmd="${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG}"
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
return 0
}

@ -61,8 +61,10 @@ function openim::msggateway::start() {
if [[ -n "${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}" ]]; then
PROMETHEUS_PORT_OPTION="--prometheus_port ${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}"
fi
cmd="${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG}"
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
# nohup ${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
nohup ${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]} --ws_port ${OPENIM_WS_PORTS_ARRAY[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
done
return 0
}

@ -57,10 +57,11 @@ function openim::msgtransfer::start() {
openim::util::stop_services_on_ports ${PROMETHEUS_MSG_TRANSFER_PORT}
PROMETHEUS_PORT_OPTION="--prometheus_port ${PROMETHEUS_MSG_TRANSFER_PORT}"
fi
nohup ${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
cmd="${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i}"
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
#nohup ${OPENIM_MSGTRANSFER_BINARY} ${PROMETHEUS_PORT_OPTION} -c ${OPENIM_MSGTRANSFER_CONFIG} -n ${i} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
done
return 0
}
function openim::msgtransfer::check() {

@ -71,7 +71,9 @@ function openim::push::start() {
for (( i=0; i<${#OPENIM_PUSH_PORTS_ARRAY[@]}; i++ )); do
openim::log::info "start push process, port: ${OPENIM_PUSH_PORTS_ARRAY[$i]}, prometheus port: ${PUSH_PROM_PORTS_ARRAY[$i]}"
nohup ${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
cmd="${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]}"
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
#nohup ${OPENIM_PUSH_BINARY} --port ${OPENIM_PUSH_PORTS_ARRAY[$i]} -c ${OPENIM_PUSH_CONFIG} --prometheus_port ${PUSH_PROM_PORTS_ARRAY[$i]} >> ${LOG_FILE} 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
done
return 0

@ -165,7 +165,8 @@ function openim::rpc::start_service() {
printf "Specifying prometheus port: %s\n" "${prometheus_port}"
cmd="${cmd} --prometheus_port ${prometheus_port}"
fi
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
#nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "${STDERR_LOG_FILE}" "$TMP_LOG_FILE" >&2) &
nohup ${cmd} >> "${LOG_FILE}" 2> >(tee -a "$TMP_LOG_FILE" | while read line; do echo -e "\e[31m${line}\e[0m"; done >&2) >/dev/null &
return 0
}

@ -238,3 +238,8 @@ function openim::log::test_log() {
}
# openim::log::test_log
function openim::log::print_blue() {
echo -e "\033[0;36m$1\033[0m"
}

@ -427,6 +427,7 @@ openim::util::check_process_names() {
fi
done
# Print information
if [[ ${#not_started[@]} -ne 0 ]]; then
echo "Not started processes:"

@ -37,7 +37,7 @@ function execute_start_scripts() {
# Check if the script file exists and is executable.
if [[ -x "$script_path" ]]; then
openim::log::info "Starting script: ${script_path##*/}" # Log the script name.
openim::log::print_blue "Starting script: ${script_path##*/}" # Log the script name.
# Execute the script with the constructed argument.
result=$("$script_path" "$arg")
@ -69,7 +69,7 @@ fi
"${OPENIM_ROOT}"/scripts/init-config.sh --skip
echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTARIES[@]}"
#openim::log::print_blue "Execute the following script in sequence: ${OPENIM_SERVER_SCRIPTARIES[@]}"
# TODO Prelaunch tools, simple for now, can abstract functions later
@ -81,7 +81,7 @@ ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start
result=$("${OPENIM_ROOT}"/scripts/stop-all.sh)
if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "View the error logs from this startup. ${LOG_FILE} \n"
openim::log::error "Some programs have not exited; the start process is aborted .\n $result"
exit 1
fi
@ -95,7 +95,6 @@ sleep 2
result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check)
if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "The program may fail to start.\n $result"
exit 1
fi
@ -103,7 +102,6 @@ fi
result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]})
if [[ $? -ne 0 ]]; then
echo "+++ cat openim log file >>> ${LOG_FILE}"
openim::log::error "The program may fail to start.\n $result"
exit 1
fi

Loading…
Cancel
Save