feat: add more test code

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-08-23 20:52:33 +08:00
parent 5b478e3d63
commit 72c7d58777
8 changed files with 236 additions and 62 deletions
+26 -14
View File
@@ -102,7 +102,7 @@ def "MONGO_MAX_POOL_SIZE" "100" # 最
###################### Object 配置信息 ######################
def "OBJECT_ENABLE" "minio" # 对象是否启用
def "OBJECT_APIURL" "http://${IP}:10002" # 对象的API地址
def "OBJECT_APIURL" "http://${IP}:10002" # 对象的API地址
def "MINIO_BUCKET" "openim" # MinIO的存储桶名称
def "MINIO_PORT" "10005" # MinIO的端口
# MinIO的端点URL
@@ -147,7 +147,7 @@ def "RPC_LISTEN_IP" "0.0.0.0" # RPC的监听IP
###################### API 配置信息 ######################
# API的开放端口, 只能设置一个端口
def "API_OPENIM_PORT" "10002"
readonly API_OPENIM_PORT=${API_OPENIM_PORT:-'10002'}
def "API_LISTEN_IP" "0.0.0.0" # API的监听IP
###################### RPC Port Configuration Variables ######################
@@ -162,7 +162,7 @@ readonly OPENIM_FRIEND_PORT=${OPENIM_FRIEND_PORT:-'10120'}
# OpenIM消息服务端口
readonly OPENIM_MESSAGE_PORT=${OPENIM_MESSAGE_PORT:-'10130'}
# OpenIM消息网关服务端口
readonly OPENIM_MESSAGE_GATEWAY_PORT=${OPENIM_MESSAGE_GATEWAY_PORT:-'10140'}
readonly OPENIM_MESSAGE_GATEWAY_PORT=${OPENIM_MESSAGE_GATEWAY_PORT:-'10140,11140'}
# OpenIM组服务端口
readonly OPENIM_GROUP_PORT=${OPENIM_GROUP_PORT:-'10150'}
# OpenIM授权服务端口
@@ -195,7 +195,8 @@ def "LOG_IS_JSON" "false" # 日志是否为JSON格式
def "LOG_WITH_STACK" "false" # 日志是否带有堆栈信息
###################### Variables definition ######################
def "OPENIM_WS_PORT" "10001" # OpenIM WS端口
# OpenIM WS端口
readonly OPENIM_WS_PORT=${OPENIM_WS_PORT:-'10001,11001'}
def "WEBSOCKET_MAX_CONN_NUM" "100000" # Websocket最大连接数
def "WEBSOCKET_MAX_MSG_LEN" "4096" # Websocket最大消息长度
def "WEBSOCKET_TIMEOUT" "10" # Websocket超时
@@ -232,16 +233,27 @@ def "IOS_PRODUCTION" "false" # IOS生产
###################### Prometheus 配置信息 ######################
def "PROMETHEUS_ENABLE" "false" # 是否启用 Prometheus
def "USER_PROM_PORT" "20110" # User 服务的 Prometheus 端口
def "FRIEND_PROM_PORT" "20120" # Friend 服务的 Prometheus 端口
def "MESSAGE_PROM_PORT" "20130" # Message 服务的 Prometheus 端口
def "MSG_GATEWAY_PROM_PORT" "20140" # Message Gateway 服务的 Prometheus 端口
def "GROUP_PROM_PORT" "20150" # Group 服务的 Prometheus 端口
def "AUTH_PROM_PORT" "20160" # Auth 服务的 Prometheus 端口
def "PUSH_PROM_PORT" "20170" # Push 服务的 Prometheus 端口
def "CONVERSATION_PROM_PORT" "20230" # Conversation 服务的 Prometheus 端口
def "RTC_PROM_PORT" "21300" # RTC 服务的 Prometheus 端口
def "THIRD_PROM_PORT" "21301" # Third 服务的 Prometheus 端口
# User 服务的 Prometheus 端口
readonly USER_PROM_PORT=${USER_PROM_PORT:-'20110'}
# Friend 服务的 Prometheus 端口
readonly FRIEND_PROM_PORT=${FRIEND_PROM_PORT:-'20120'}
# Message 服务的 Prometheus 端口
readonly MESSAGE_PROM_PORT=${MESSAGE_PROM_PORT:-'20130'}
# Message Gateway 服务的 Prometheus 端口
readonly MSG_GATEWAY_PROM_PORT=${MSG_GATEWAY_PROM_PORT:-'20140,21140'}
# Group 服务的 Prometheus 端口
readonly GROUP_PROM_PORT=${GROUP_PROM_PORT:-'20150'}
# Auth 服务的 Prometheus 端口
readonly AUTH_PROM_PORT=${AUTH_PROM_PORT:-'20160'}
# Push 服务的 Prometheus 端口
readonly PUSH_PROM_PORT=${PUSH_PROM_PORT:-'20170'}
# Conversation 服务的 Prometheus 端口
readonly CONVERSATION_PROM_PORT=${CONVERSATION_PROM_PORT:-'20230'}
# RTC 服务的 Prometheus 端口
readonly RTC_PROM_PORT=${RTC_PROM_PORT:-'21300'}
# Third 服务的 Prometheus 端口
readonly THIRD_PROM_PORT=${THIRD_PROM_PORT:-'21301'}
# Message Transfer 服务的 Prometheus 端口列表
readonly MSG_TRANSFER_PROM_PORT=${MSG_TRANSFER_PROM_PORT:-'21400, 21401, 21402, 21403'}
+17 -13
View File
@@ -33,32 +33,36 @@ function openim::msggateway::start()
openim::util::stop_services_with_name ${SERVER_NAME}
# OpenIM message gateway service port
OPENIM_RPC_PORTS=$(openim::util::list-to-string ${OPENIM_MESSAGE_GATEWAY_PORT} )
OPENIM_MESSAGE_GATEWAY_PORTS=$(openim::util::list-to-string ${OPENIM_MESSAGE_GATEWAY_PORT} )
read -a OPENIM_MSGGATEWAY_PORTS_ARRAY <<< $(openim::util::list-to-string ${OPENIM_MESSAGE_GATEWAY_PORT} )
# OpenIM WS port
OPENIM_WS_PORTS=$(openim::util::list-to-string ${OPENIM_WS_PORT} )
read -a OPENIM_WS_PORTS_ARRAY <<< $(openim::util::list-to-string ${OPENIM_WS_PORT} )
# Message Gateway Prometheus port of the service
MSG_GATEWAY_PROM_PORTS=$(openim::util::list-to-string ${MSG_GATEWAY_PROM_PORT} )
read -a MSG_GATEWAY_PROM_PORTS_ARRAY <<< $(openim::util::list-to-string ${MSG_GATEWAY_PROM_PORT} )
openim::log::status "OpenIM RPC ports: ${OPENIM_RPC_PORTS[*]}"
openim::log::status "OpenIM Mssage Getway ports: ${OPENIM_MESSAGE_GATEWAY_PORTS[*]}"
openim::log::status "OpenIM WS ports: ${OPENIM_WS_PORTS[*]}"
openim::log::status "OpenIM Prometheus ports: ${MSG_GATEWAY_PROM_PORTS[*]}"
openim::log::status "OpenIM Msggateway config path: ${OPENIM_MSGGATEWAY_CONFIG}"
if [ ${#OPENIM_RPC_PORTS[@]} -ne ${#OPENIM_WS_PORTS[@]} ]; then
openim::log::error "ws_ports does not match push_rpc_ports or prome_ports in quantity!!!"
exit 1
if [ ${#OPENIM_MSGGATEWAY_PORTS_ARRAY[@]} -ne ${#OPENIM_WS_PORTS_ARRAY[@]} ]; then
openim::log::error_exit "ws_ports does not match push_rpc_ports or prome_ports in quantity!!!"
fi
for ((i = 0; i < ${#OPENIM_WS_PORTS[@]}; i++)); do
openim::log::info "start push process, port: ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]}, prometheus port: ${PUSH_MSGGATEWAY_PORTS_ARRAY[$i]}"
PROMETHEUS_PORT_OPTION=""
if [[ -n "${MSG_GATEWAY_PROM_PORTS[$i]}" ]]; then
PROMETHEUS_PORT_OPTION="--prometheus_port ${MSG_GATEWAY_PROM_PORTS[$i]}"
fi
for ((i = 0; i < ${#OPENIM_WS_PORTS_ARRAY[@]}; i++)); do
openim::log::info "start push process, port: ${OPENIM_MSGGATEWAY_PORTS_ARRAY[$i]}, prometheus port: ${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}"
nohup ${OPENIM_MSGGATEWAY_BINARY} --port ${OPENIM_RPC_PORTS[$i]} --ws_port ${OPENIM_WS_PORTS[$i]} $PROMETHEUS_PORT_OPTION -c ${OPENIM_MSGGATEWAY_CONFIG} >> ${LOG_FILE} 2>&1 &
PROMETHEUS_PORT_OPTION=""
if [[ -n "${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}" ]]; then
PROMETHEUS_PORT_OPTION="--prometheus_port ${MSG_GATEWAY_PROM_PORTS_ARRAY[$i]}"
fi
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>&1 &
done
openim::util::check_process_names ${SERVER_NAME}
-1
View File
@@ -128,7 +128,6 @@ function openim::rpc::start() {
# Get the service and Prometheus ports.
OPENIM_RPC_SERVICE_PORTS=( $(openim::util::list-to-string ${OPENIM_RPC_PORT_LISTARIES[$i]}) )
OPENIM_RPC_PROM_PORTS=( $(openim::util::list-to-string ${OPENIM_RPC_PROM_PORT_LISTARIES[$i]}) )
for ((j = 0; j < ${#OPENIM_RPC_SERVICE_PORTS[@]}; j++)); do
openim::log::info "Starting ${OPENIM_RPC_SERVICE_LISTARIES[$i]} service, port: ${OPENIM_RPC_SERVICE_PORTS[j]}, prometheus port: ${OPENIM_RPC_PROM_PORTS[j]}, binary root: ${OPENIM_OUTPUT_HOSTBIN}/${OPENIM_RPC_SERVICE_LISTARIES[$i]}"
openim::rpc::start_service "${OPENIM_RPC_SERVICE_LISTARIES[$i]}" "${OPENIM_RPC_SERVICE_PORTS[j]}" "${OPENIM_RPC_PROM_PORTS[j]}"
+2 -2
View File
@@ -895,13 +895,13 @@ function openim::util::list-to-string() {
# 2. Replace commas with spaces
# 3. Remove opening and closing brackets
ports_array=$(echo "$ports_list" | sed 's/ //g; s/,/ /g; s/^\[\(.*\)\]$/\1/')
# For external use, we might want to echo the result so that it can be captured by callers
echo "$ports_array"
}
# MSG_GATEWAY_PROM_PORTS=$(openim::util::list-to-string "10023, 2323, 34 34")
# read -a MSG_GATEWAY_PROM_PORTS <<< $(openim::util::list-to-string "10023, 2323, 34 34")
# echo ${MSG_GATEWAY_PROM_PORTS}
# echo "${#MSG_GATEWAY_PROM_PORTS[@]}"
# Downloads cfssl/cfssljson/cfssl-certinfo into $1 directory if they do not already exist in PATH
#
# Assumed vars: