You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/script/start_rpc_service.sh

89 lines
2.4 KiB

#!/usr/bin/env bash
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
#service filename
service_filename=(
#api
open_im_api
#rpc
open_im_user
open_im_friend
open_im_group
open_im_auth
${msg_name}
open_im_conversation
2 years ago
open_im_third
)
#service config port name
service_port_name=(
#api port name
openImApiPort
#rpc port name
openImUserPort
openImFriendPort
openImGroupPort
3 years ago
openImAuthPort
3 years ago
openImMessagePort
openImConversationPort
2 years ago
openImThirdPort
)
2 years ago
service_prometheus_port_name=(
#api port name
openImApiPort
#rpc port name
userPrometheusPort
friendPrometheusPort
groupPrometheusPort
authPrometheusPort
messagePrometheusPort
conversationPrometheusPort
2 years ago
thirdPrometheusPort
2 years ago
)
for ((i = 0; i < ${#service_filename[*]}; i++)); do
#Check whether the service exists
service_name="ps -aux |grep -w ${service_filename[$i]} |grep -v grep"
count="${service_name}| wc -l"
if [ $(eval ${count}) -gt 0 ]; then
pid="${service_name}| awk '{print \$2}'"
3 years ago
echo "${service_filename[$i]} service has been started,pid:$(eval $pid)"
echo "killing the service ${service_filename[$i]} pid:$(eval $pid)"
#kill the service that existed
kill -9 $(eval $pid)
sleep 0.5
fi
3 years ago
cd ../bin
#Get the rpc port in the configuration file
portList=$(cat $config_path | grep ${service_port_name[$i]} | awk -F '[:]' '{print $NF}')
list_to_string ${portList}
2 years ago
service_ports=($ports_array)
2 years ago
portList2=$(cat $config_path | grep ${service_prometheus_port_name[$i]} | awk -F '[:]' '{print $NF}')
2 years ago
list_to_string $portList2
prome_ports=($ports_array)
#Start related rpc services based on the number of ports
2 years ago
for ((j = 0; j < ${#service_ports[*]}; j++)); do
#Start the service in the background
2 years ago
if [ -z "${prome_ports[$j]}" ]; then
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
else
cmd="./${service_filename[$i]} --port ${service_ports[$j]} --prometheus_port ${prome_ports[$j]}"
fi
2 years ago
if [ $i -eq 0 -o $i -eq 1 ]; then
2 years ago
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
2 years ago
fi
echo $cmd
2 years ago
echo "=====================start ${service_filename[$i]}======================">>../logs/openIM.log
2 years ago
nohup $cmd >>../logs/openIM.log 2>&1 &
sleep 1
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
2 years ago
echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX"
done
3 years ago
done