mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 13:05:58 +08:00
refactor: 3.7.0 code conventions. (#2148)
* Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: add code lint * feat: add code lint * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * Script Refactoring * feat: code format * Script Refactoring * Script Refactoring * Script Refactoring * Adjust MinIO configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: config change. * refactor: webhooks update. * Adjust configuration settings * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * feat: s3 api addr * refactor: webhooks update. * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * Adjust configuration settings * refactor: webhooks update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * refactor: kafka update. * refactor: kafka update. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Simplify the Docker Compose configuration, remove unnecessary environment variables, and eliminate the gateway service. * Windows can compile and run. * Windows can compile and run. * refactor: kafka update. * feat: msg cache split * refactor: webhooks update * refactor: webhooks update * refactor: friends update * refactor: group update * refactor: third update * refactor: api update * refactor: crontab update * refactor: msggateway update * mage * mage * refactor: all module update. * check * refactor: all module update. * load config * load config * load config * load config * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * refactor: all module update. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update tools * update tools * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * update protocol * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: all module update. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * Optimize Docker configuration and script. * refactor: api remove token auth by redis directly. * Code Refactoring * refactor: websocket auth change to call rpc of auth. * refactor: kick online user and remove token change to call auth rpc. * refactor: kick online user and remove token change to call auth rpc. * refactor: remove msggateway redis. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor webhook * refactor: cmd update. * refactor: cmd update. * fix: runtime: goroutine stack exceeds * refactor: cmd update. * refactor notification * refactor notification * refactor * refactor: cmd update. * refactor: cmd update. * refactor * refactor * refactor * protojson * protojson * protojson * go mod * wrapperspb * refactor: cmd update. * refactor: cmd update. * refactor: cmd update. * refactor: context update. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: websocket update info. * refactor: api name change. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: update file * refactor * refactor * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * refactor: debug info. * fix: callback update. * fix: callback update. * refactor * fix: update message. * fix: msg cache timeout. * refactor * refactor * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: push update. * fix: websocket handle error remove when upgrade error. --------- Co-authored-by: skiffer-git <44203734@qq.com> Co-authored-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Co-authored-by: withchao <993506633@qq.com>
This commit is contained in:
@@ -149,7 +149,7 @@ openim::golang::start_script_list() {
|
||||
openim-msgtransfer.sh
|
||||
openim-msggateway.sh
|
||||
openim-crontask.sh
|
||||
openim-tools.sh
|
||||
#openim-tools.sh
|
||||
)
|
||||
local result=()
|
||||
for target in "${targets[@]}"; do
|
||||
@@ -181,7 +181,7 @@ openim::golang::check_openim_binaries() {
|
||||
done
|
||||
return 1
|
||||
else
|
||||
echo "All binaries have been installed in ${OPENIM_OUTPUT_HOSTBIN}。"
|
||||
echo -e "All binaries have been installed in: \n${OPENIM_OUTPUT_HOSTBIN}\n${OPENIM_OUTPUT_HOSTBIN_TOOLS}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
@@ -317,8 +317,6 @@ readonly OPENIM_CLIENT_TARGETS=(
|
||||
imctl
|
||||
infra
|
||||
ncpu
|
||||
openim-web
|
||||
up35
|
||||
versionchecker
|
||||
yamlfmt
|
||||
)
|
||||
|
||||
+25
-5
@@ -210,16 +210,26 @@ openim::log::status() {
|
||||
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]")
|
||||
echo_log "${timestamp} ${1}"
|
||||
|
||||
local COLOR_BLUE="\033[0;34m"
|
||||
local COLOR_RESET="\033[0m"
|
||||
|
||||
local timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]")
|
||||
|
||||
echo_log() {
|
||||
echo -e "$@"
|
||||
}
|
||||
|
||||
|
||||
echo_log "${COLOR_BLUE}${timestamp} ${1}${COLOR_RESET}"
|
||||
shift
|
||||
for message; do
|
||||
echo_log " ${message}"
|
||||
echo_log "${COLOR_BLUE}${message}${COLOR_RESET}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
openim::log::success() {
|
||||
local V="${V:-0}"
|
||||
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
|
||||
@@ -232,7 +242,6 @@ openim::log::success() {
|
||||
|
||||
|
||||
|
||||
|
||||
function openim::log::test_log() {
|
||||
echo_log "test log"
|
||||
openim::log::info "openim::log::info"
|
||||
@@ -249,3 +258,14 @@ function openim::log::print_blue() {
|
||||
echo -e "\033[0;36m$1\033[0m"
|
||||
}
|
||||
|
||||
|
||||
openim::log::colorless() {
|
||||
local V="${V:-0}"
|
||||
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
|
||||
return
|
||||
fi
|
||||
timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]")
|
||||
echo_log -e "${timestamp} ${1} "
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ function openim::release::package_client_tarballs() {
|
||||
|
||||
local client_bins=("${OPENIM_CLIENT_BINARIES[@]}")
|
||||
|
||||
# client_bins: changelog component imctl infra ncpu openim-web up35 versionchecker yamlfmt
|
||||
# client_bins: changelog component imctl infra ncpu versionchecker yamlfmt
|
||||
# Copy client binclient_bins:aries
|
||||
openim::log::info " Copy client binaries: ${client_bins[@]/#/${LOCAL_OUTPUT_BINTOOLSPATH}/${platform}/}"
|
||||
openim::log::info " Copy client binaries to: ${release_stage}/client/bin"
|
||||
|
||||
+62
-19
@@ -360,8 +360,8 @@ openim::util::check_ports() {
|
||||
|
||||
# If any of the processes is not running, return a status of 1.
|
||||
if [[ ${#not_started[@]} -ne 0 ]]; then
|
||||
openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
#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"}'
|
||||
return 1
|
||||
else
|
||||
@@ -446,8 +446,8 @@ openim::util::check_process_names() {
|
||||
|
||||
# Return status
|
||||
if [[ ${#not_started[@]} -ne 0 ]]; then
|
||||
openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}"
|
||||
openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}"
|
||||
#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"}'
|
||||
return 1
|
||||
else
|
||||
@@ -599,33 +599,36 @@ openim::util::stop_services_with_name() {
|
||||
# An array to collect information about processes that were stopped.
|
||||
local stopped=()
|
||||
|
||||
echo "Stopping services with names: $*"
|
||||
# Iterate over each given service name.
|
||||
for server_name in "$@"; do
|
||||
# Use the `pgrep` command to find process IDs related to the given service name.
|
||||
local pids=$(pgrep -f "$server_name")
|
||||
|
||||
# If no process was found with the name, add it to the not_stopped list
|
||||
if [[ -z $pids ]]; then
|
||||
not_stopped+=("$server_name")
|
||||
continue
|
||||
fi
|
||||
local stopped_this_time=false
|
||||
for pid in $pids; do
|
||||
for pid in $pids; do
|
||||
|
||||
# Exclude the PID of the current script
|
||||
if [[ "$pid" == "$$" ]]; then
|
||||
continue
|
||||
fi
|
||||
# Exclude the PID of the current script
|
||||
if [[ "$pid" == "$$" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# If there's a Process ID, it means the service with the name is running.
|
||||
if [[ -n $pid ]]; then
|
||||
# Print the binary path for the PID
|
||||
binary_path=$(readlink -f /proc/$pid/exe)
|
||||
openim::log::colorless "stop PID $pid full path: $binary_path"
|
||||
|
||||
# Try to stop the service by killing its process.
|
||||
if kill -15 $pid 2>/dev/null; then
|
||||
stopped_this_time=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# If there's a Process ID, it means the service with the name is running.
|
||||
if [[ -n $pid ]]; then
|
||||
# Try to stop the service by killing its process.
|
||||
if kill -15 $pid 2>/dev/null; then
|
||||
stopped_this_time=true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if $stopped_this_time; then
|
||||
stopped+=("$server_name")
|
||||
@@ -2848,6 +2851,46 @@ function openim::util::check_process_names_for_stop() {
|
||||
|
||||
|
||||
|
||||
function openim::util::find_process_ports() {
|
||||
local process_path="$1"
|
||||
if [[ -z "$process_path" ]]; then
|
||||
echo "Usage: find_process_ports /path/to/process"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local protocol_ports=""
|
||||
while read -r line; do
|
||||
local port_protocol=($line)
|
||||
local port=${port_protocol[0]##*:}
|
||||
local protocol=${port_protocol[1]}
|
||||
protocol_ports="${protocol_ports}${protocol} ${port}, "
|
||||
|
||||
done < <(lsof -nP -iTCP -iUDP | grep LISTEN | grep "$(pgrep -f "$process_path")" | awk '{print $9, $8}')
|
||||
|
||||
protocol_ports=${protocol_ports%, }
|
||||
|
||||
if [[ -z "$protocol_ports" ]]; then
|
||||
openim::log::colorless "$process_path is not listening on any ports"
|
||||
else
|
||||
openim::log::colorless "$process_path is listening on protocol & port: $protocol_ports"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function openim::util::find_ports_for_all_services() {
|
||||
local services=("$@")
|
||||
for service in "${services[@]}"; do
|
||||
openim::util::find_process_ports "$service"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [[ "$*" =~ openim::util:: ]];then
|
||||
eval $*
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user