mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-27 22:12:15 +08:00
feat: add file save
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
parent
30c0decaeb
commit
c47e073db8
@ -30,29 +30,10 @@ source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
# Make sure the environment is only called via common to avoid too much nesting
|
||||
source "${OPENIM_ROOT}/scripts/install/environment.sh"
|
||||
|
||||
# Make sure the environment is only called via common to avoid too much nesting
|
||||
openim::common::rpc::service_port() {
|
||||
local targets=(
|
||||
$OPENIM_USER_PORT # User service
|
||||
$OPENIM_FRIEND_PORT # Friend service
|
||||
$OPENIM_MESSAGE_PORT # Message service
|
||||
$OPENIM_MESSAGE_GATEWAY_PORT # Message gateway
|
||||
$OPENIM_GROUP_PORT # Group service
|
||||
$OPENIM_AUTH_PORT # Authorization service
|
||||
$OPENIM_PUSH_PORT # Push service
|
||||
$OPENIM_CONVERSATION_PORT # Conversation service
|
||||
$OPENIM_THIRD_PORT # Third-party service
|
||||
)
|
||||
echo "${targets[@]}"
|
||||
}
|
||||
IFS=" " read -ra OPENIM_RPC_PORT_TARGETS <<< "$(openim::common::rpc::service_port)"
|
||||
readonly OPENIM_RPC_PORT_TARGETS
|
||||
readonly OPENIM_RPC_PORT_LISTARIES=("${OPENIM_RPC_PORT_TARGETS[@]##*/}")
|
||||
|
||||
# This function returns a list of Prometheus ports for various services
|
||||
# based on the provided configuration. Each service has its own dedicated
|
||||
# port for monitoring purposes.
|
||||
openim::common::rpc::prometheus_port() {
|
||||
openim::common::prometheus_port() {
|
||||
# Declare an array to hold all the Prometheus ports for different services
|
||||
local targets=(
|
||||
${USER_PROM_PORT} # Prometheus port for user service
|
||||
@ -70,7 +51,7 @@ openim::common::rpc::prometheus_port() {
|
||||
# Print the list of ports
|
||||
echo "${targets[@]}"
|
||||
}
|
||||
IFS=" " read -ra OPENIM_PROM_PORT_TARGETS <<< "$(openim::common::rpc::prometheus_port)"
|
||||
IFS=" " read -ra OPENIM_PROM_PORT_TARGETS <<< "$(openim::common::prometheus_port)"
|
||||
readonly OPENIM_PROM_PORT_TARGETS
|
||||
readonly OPENIM_PROM_PORT_LISTARIES=("${OPENIM_PROM_PORT_TARGETS[@]##*/}")
|
||||
|
||||
@ -78,19 +59,19 @@ readonly OPENIM_PROM_PORT_LISTARIES=("${OPENIM_PROM_PORT_TARGETS[@]##*/}")
|
||||
# This array consolidates the port numbers for all the services defined above.
|
||||
openim::common::service_port() {
|
||||
local targets=(
|
||||
$OPENIM_USER_PORT # User service
|
||||
$OPENIM_FRIEND_PORT # Friend service
|
||||
$OPENIM_MESSAGE_PORT # Message service
|
||||
$OPENIM_MESSAGE_GATEWAY_PORT # Message gateway
|
||||
$OPENIM_GROUP_PORT # Group service
|
||||
$OPENIM_AUTH_PORT # Authorization service
|
||||
$OPENIM_PUSH_PORT # Push service
|
||||
$OPENIM_CONVERSATION_PORT # Conversation service
|
||||
$OPENIM_THIRD_PORT # Third-party service
|
||||
${OPENIM_USER_PORT} # User service
|
||||
${OPENIM_FRIEND_PORT} # Friend service
|
||||
${OPENIM_MESSAGE_PORT} # Message service
|
||||
${OPENIM_MESSAGE_GATEWAY_PORT} # Message gateway
|
||||
${OPENIM_GROUP_PORT} # Group service
|
||||
${OPENIM_AUTH_PORT} # Authorization service
|
||||
${OPENIM_PUSH_PORT} # Push service
|
||||
${OPENIM_CONVERSATION_PORT} # Conversation service
|
||||
${OPENIM_THIRD_PORT} # Third-party service
|
||||
|
||||
# API PORT
|
||||
$API_OPENIM_PORT # API service
|
||||
$OPENIM_WS_PORT # WebSocket service
|
||||
${API_OPENIM_PORT} # API service
|
||||
${OPENIM_WS_PORT} # WebSocket service
|
||||
)
|
||||
echo "${targets[@]}"
|
||||
}
|
||||
@ -98,6 +79,31 @@ IFS=" " read -ra OPENIM_SERVER_PORT_TARGETS <<< "$(openim::common::service_port)
|
||||
readonly OPENIM_SERVER_PORT_TARGETS
|
||||
readonly OPENIM_SERVER_PORT_LISTARIES=("${OPENIM_SERVER_PORT_TARGETS[@]##*/}")
|
||||
|
||||
openim::rpc::service_name() {
|
||||
local targets=(
|
||||
openim-rpc-user
|
||||
openim-rpc-friend
|
||||
openim-rpc-msg
|
||||
openim-rpc-group
|
||||
openim-rpc-auth
|
||||
openim-rpc-conversation
|
||||
openim-rpc-third
|
||||
)
|
||||
echo "${targets[@]}"
|
||||
}
|
||||
IFS=" " read -ra OPENIM_RPC_SERVICE_TARGETS <<< "$(openim::rpc::service_name)"
|
||||
readonly OPENIM_RPC_SERVICE_TARGETS
|
||||
readonly OPENIM_RPC_SERVICE_LISTARIES=("${OPENIM_RPC_SERVICE_TARGETS[@]##*/}")
|
||||
|
||||
readonly OPENIM_API_SERVICE_TARGETS=(
|
||||
openim-api
|
||||
)
|
||||
readonly OPENIM_API_SERVICE_LISTARIES=("${OPENIM_API_SERVICE_TARGETS[@]##*/}")
|
||||
|
||||
readonly OPENIM_API_PORT_TARGETS=(
|
||||
${API_OPENIM_PORT}
|
||||
)
|
||||
readonly OPENIM_API_PORT_LISTARIES=("${OPENIM_API_PORT_TARGETS[@]##*/}")
|
||||
|
||||
# Execute commands that require root permission without entering a password
|
||||
function openim::common::sudo {
|
||||
|
||||
0
scripts/install/openim-api.sh
Normal file
0
scripts/install/openim-api.sh
Normal file
@ -30,16 +30,16 @@ openim::log::status "Start OpenIM Msggateway, path: ${OPENIM_MSGGATEWAY_BINARY}"
|
||||
|
||||
openim::util::stop_services_with_name ${SERVER_NAME}
|
||||
|
||||
# OpenIM消息网关服务端口
|
||||
# OpenIM message gateway service port
|
||||
OPENIM_RPC_PORTS=(openim::util::list-to-string ${OPENIM_MESSAGE_GATEWAY_PORT} )
|
||||
# OpenIM WS端口
|
||||
# OpenIM WS port
|
||||
OPENIM_WS_PORTS=(openim::util::list-to-string ${OPENIM_WS_PORT} )
|
||||
# Message Gateway 服务的 Prometheus 端口
|
||||
# Message Gateway Prometheus port of the service
|
||||
MSG_GATEWAY_PROM_PORTS=(openim::util::list-to-string ${MSG_GATEWAY_PROM_PORT} )
|
||||
|
||||
openim::log::status "OpenIM RPC ports: ${OPENIM_RPC_PORTS[@]}"
|
||||
openim::log::status "OpenIM WS ports: ${OPENIM_WS_PORTS[@]}"
|
||||
openim::log::status "OpenIM Prometheus ports: ${MSG_GATEWAY_PROM_PORTS[@]}"
|
||||
openim::log::status "OpenIM RPC ports: ${OPENIM_RPC_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}"
|
||||
|
||||
|
||||
@ -30,10 +30,10 @@ openim::log::status "Start OpenIM Msggateway, path: ${OPENIM_MSGTRANSFER_BINARY}
|
||||
|
||||
openim::util::stop_services_with_name ${SERVER_NAME}
|
||||
|
||||
# Message Transfer 服务的 Prometheus 端口列表
|
||||
# Message Transfer Prometheus port list
|
||||
MSG_TRANSFER_PROM_PORTS=(openim::util::list-to-string ${MSG_TRANSFER_PROM_PORT} )
|
||||
|
||||
openim::log::status "OpenIM Prometheus ports: ${MSG_TRANSFER_PROM_PORTS[@]}"
|
||||
openim::log::status "OpenIM Prometheus ports: ${MSG_TRANSFER_PROM_PORTS[*]}"
|
||||
|
||||
openim::log::status "OpenIM Msggateway config path: ${OPENIM_MSGTRANSFER_CONFIG}"
|
||||
|
||||
|
||||
@ -23,47 +23,151 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
|
||||
|
||||
SERVER_NAME="openim-rpc"
|
||||
|
||||
#service filename
|
||||
service_filename=(
|
||||
#api
|
||||
openim-api
|
||||
#rpc
|
||||
openim-rpc-user
|
||||
openim-rpc-friend
|
||||
openim-rpc-group
|
||||
openim-rpc-auth
|
||||
${msg_name}
|
||||
openim-rpc-conversation
|
||||
openim-rpc-third
|
||||
readonly OPENIM_RPC_ALL_NAME_TARGETS=(
|
||||
"${OPENIM_API_SERVICE_TARGETS[@]}"
|
||||
"${OPENIM_RPC_SERVICE_TARGETS[@]}"
|
||||
)
|
||||
readonly OPENIM_RPC_ALL_NAME_LISTARIES=("${OPENIM_RPC_ALL_NAME_TARGETS[@]##*/}")
|
||||
|
||||
#service config port name
|
||||
service_port_name=(
|
||||
#api port name
|
||||
openImApiPort
|
||||
#rpc port name
|
||||
openImUserPort
|
||||
openImFriendPort
|
||||
openImGroupPort
|
||||
openImAuthPort
|
||||
openImMessagePort
|
||||
openImConversationPort
|
||||
openImThirdPort
|
||||
# Make sure the environment is only called via common to avoid too much nesting
|
||||
openim::rpc::service_port() {
|
||||
local targets=(
|
||||
${OPENIM_USER_PORT} # User service 10110
|
||||
${OPENIM_FRIEND_PORT} # Friend service 10120
|
||||
${OPENIM_MESSAGE_PORT} # Message service 10130
|
||||
# ${OPENIM_MESSAGE_GATEWAY_PORT} # Message gateway 10140
|
||||
${OPENIM_GROUP_PORT} # Group service 10150
|
||||
${OPENIM_AUTH_PORT} # Authorization service 10160
|
||||
# ${OPENIM_PUSH_PORT} # Push service 10170
|
||||
${OPENIM_CONVERSATION_PORT} # Conversation service 10180
|
||||
${OPENIM_THIRD_PORT} # Third-party service 10190
|
||||
)
|
||||
echo "${targets[@]}"
|
||||
}
|
||||
IFS=" " read -ra OPENIM_RPC_PORT_TARGETS <<< "$(openim::rpc::service_port)"
|
||||
readonly OPENIM_RPC_PORT_TARGETS
|
||||
readonly OPENIM_RPC_PORT_LISTARIES=("${OPENIM_RPC_PORT_TARGETS[@]##*/}")
|
||||
|
||||
readonly OPENIM_RPC_ALL_PORT_TARGETS=(
|
||||
"${OPENIM_API_PORT_TARGETS[@]}"
|
||||
"${OPENIM_RPC_PORT_TARGETS[@]}"
|
||||
)
|
||||
readonly OPENIM_RPC_ALL_PORT_LISTARIES=("${OPENIM_RPC_ALL_PORT_TARGETS[@]##*/}")
|
||||
|
||||
service_prometheus_port_name=(
|
||||
#api port name
|
||||
openImApiPort
|
||||
#rpc port name
|
||||
userPrometheusPort
|
||||
friendPrometheusPort
|
||||
groupPrometheusPort
|
||||
authPrometheusPort
|
||||
messagePrometheusPort
|
||||
conversationPrometheusPort
|
||||
thirdPrometheusPort
|
||||
openim::rpc::prometheus_port() {
|
||||
# Declare an array to hold all the Prometheus ports for different services
|
||||
local targets=(
|
||||
${USER_PROM_PORT} # Prometheus port for user service
|
||||
${FRIEND_PROM_PORT} # Prometheus port for friend service
|
||||
${MESSAGE_PROM_PORT} # Prometheus port for message service
|
||||
${GROUP_PROM_PORT} # Prometheus port for group service
|
||||
${AUTH_PROM_PORT} # Prometheus port for authentication service
|
||||
${CONVERSATION_PROM_PORT} # Prometheus port for conversation service
|
||||
${THIRD_PROM_PORT} # Prometheus port for third-party integrations service
|
||||
)
|
||||
# Print the list of ports
|
||||
echo "${targets[@]}"
|
||||
}
|
||||
IFS=" " read -ra OPENIM_RPC_PROM_PORT_TARGETS <<< "$(openim::rpc::prometheus_port)"
|
||||
readonly OPENIM_RPC_PROM_PORT_TARGETS
|
||||
readonly OPENIM_RPC_PROM_PORT_LISTARIES=("${OPENIM_RPC_PROM_PORT_TARGETS[@]##*/}")
|
||||
|
||||
readonly OPENIM_RPC_ALL_PROM_PORT_TARGETS=(
|
||||
"${OPENIM_API_PORT_TARGETS[@]}"
|
||||
"${OPENIM_RPC_PROM_PORT_TARGETS[@]}"
|
||||
)
|
||||
readonly OPENIM_RPC_ALL_PROM_PORT_LISTARIES=("${OPENIM_RPC_ALL_PROM_PORT_TARGETS[@]##*/}")
|
||||
|
||||
openim::log::info "Starting ${SERVER_NAME} ..."
|
||||
|
||||
printf "+------------------------+-------+-----------------+\n"
|
||||
printf "| Service Name | Port | Prometheus Port |\n"
|
||||
printf "+------------------------+-------+-----------------+\n"
|
||||
|
||||
length=${#OPENIM_RPC_ALL_NAME_LISTARIES[@]}
|
||||
|
||||
for ((i=0; i<$length; i++)); do
|
||||
printf "| %-22s | %-5s | %-15s |\n" "${OPENIM_RPC_ALL_NAME_LISTARIES[$i]}" "${OPENIM_RPC_ALL_PORT_LISTARIES[$i]}" "${OPENIM_RPC_ALL_PROM_PORT_LISTARIES[$i]}"
|
||||
printf "+------------------------+-------+-----------------+\n"
|
||||
done
|
||||
|
||||
# #service filename
|
||||
# service_filename=(
|
||||
# #api
|
||||
# openim-api
|
||||
# #rpc
|
||||
# openim-rpc-user
|
||||
# openim-rpc-friend
|
||||
# openim-rpc-msg
|
||||
# openim-rpc-group
|
||||
# openim-rpc-auth
|
||||
# openim-rpc-conversation
|
||||
# openim-rpc-third
|
||||
# )
|
||||
|
||||
# #service config port name
|
||||
# service_port_name=(
|
||||
# #api port name
|
||||
# openImApiPort
|
||||
# #rpc port name
|
||||
|
||||
# openImUserPort 10110
|
||||
# openImFriendPort 10120
|
||||
# openImMessagePort 10130
|
||||
# openImGroupPort 10150
|
||||
# openImAuthPort 10160
|
||||
# openImConversationPort 10180
|
||||
# openImThirdPort 10190
|
||||
# )
|
||||
|
||||
# service_prometheus_port_name=(
|
||||
# #api port name
|
||||
# openImApiPort //${API_OPENIM_PORT}
|
||||
# #rpc port name
|
||||
# userPrometheusPort
|
||||
# friendPrometheusPort
|
||||
# groupPrometheusPort
|
||||
# authPrometheusPort
|
||||
# messagePrometheusPort
|
||||
# conversationPrometheusPort
|
||||
# thirdPrometheusPort
|
||||
# )
|
||||
|
||||
|
||||
# This function starts a service based on the provided filename, port, and optional Prometheus port.
|
||||
start_service() {
|
||||
local cmd="./$1 --port $2 -c ${configfile_path}"
|
||||
if [ -n "$3" ]; then
|
||||
cmd="${cmd} --prometheus_port $3"
|
||||
fi
|
||||
echo "=====================start $1======================" >>$OPENIM_ROOT/logs/openIM.log
|
||||
nohup $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
||||
sleep 1
|
||||
local pid="netstat -ntlp|grep $2 |awk '{printf \$7}'|cut -d/ -f1"
|
||||
echo -e "${GREEN_PREFIX}$1 start success, port number:$2 pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
}
|
||||
|
||||
cd $OPENIM_ROOT
|
||||
cd $BIN_DIR
|
||||
|
||||
echo "xxxxxxxxxxxxxxxxxxxxxxxx ${#OPENIM_RPC_ALL_NAME_TARGETS[*]}"
|
||||
|
||||
openim::util::stop_services_with_name ${#OPENIM_RPC_ALL_NAME_TARGETS[*]}
|
||||
|
||||
# Assuming OPENIM_RPC_ALL_NAME_TARGETS and other variables have been defined from the previous refactor.
|
||||
for ((i = 0; i < ${#OPENIM_RPC_ALL_NAME_TARGETS[*]}; i++)); do
|
||||
openim::util::stop_services_with_name "${OPENIM_RPC_ALL_NAME_TARGETS[$i]}"
|
||||
|
||||
# Get the service and Prometheus ports.
|
||||
service_ports=($(cat $config_path | grep ${OPENIM_RPC_ALL_PORT_TARGETS[$i]} | awk -F '[:]' '{print $NF}'))
|
||||
prome_ports=($(cat $config_path | grep ${OPENIM_RPC_ALL_PROM_PORT_TARGETS[$i]} | awk -F '[:]' '{print $NF}'))
|
||||
|
||||
for ((j = 0; j < ${#service_ports[*]}; j++)); do
|
||||
start_service "${OPENIM_RPC_ALL_NAME_TARGETS[$i]}" "${service_ports[$j]}" "${prome_ports[$j]}"
|
||||
done
|
||||
done
|
||||
|
||||
# ---
|
||||
for ((i = 0; i < ${#service_filename[*]}; i++)); do
|
||||
#Check whether the service exists
|
||||
service_name="ps |grep -w ${service_filename[$i]} |grep -v grep"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user