parent
51cef0bc53
commit
0cc641d1f8
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
bin_dir="../bin"
|
||||
logs_dir="../logs"
|
||||
sdk_db_dir="../db/sdk/"
|
||||
#Automatically created when there is no bin, logs folder
|
||||
if [ ! -d $bin_dir ]; then
|
||||
mkdir -p $bin_dir
|
||||
fi
|
||||
if [ ! -d $logs_dir ]; then
|
||||
mkdir -p $logs_dir
|
||||
fi
|
||||
if [ ! -d $sdk_db_dir ]; then
|
||||
mkdir -p $sdk_db_dir
|
||||
fi
|
||||
|
||||
#begin path
|
||||
begin_path=$PWD
|
||||
|
||||
for ((i = 0; i < ${#service_source_root[*]}; i++)); do
|
||||
cd $begin_path
|
||||
service_path=${service_source_root[$i]}
|
||||
cd $service_path && echo -e "${SKY_BLUE_PREFIX}Current directory: $PWD $COLOR_SUFFIX"
|
||||
make install && echo -e "${SKY_BLUE_PREFIX}build ${service_names[$i]} success,moving binary file to the bin directory${COLOR_SUFFIX}" &&
|
||||
echo -e "${SKY_BLUE_PREFIX}Successful moved ${service_names[$i]} to the bin directory${COLOR_SUFFIX}\n"
|
||||
done
|
@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
service_port_name=(
|
||||
openImApiPort
|
||||
openImUserPort
|
||||
openImFriendPort
|
||||
openImOfflineMessagePort
|
||||
openImOnlineRelayPort
|
||||
openImGroupPort
|
||||
openImAuthPort
|
||||
openImPushPort
|
||||
openImWsPort
|
||||
openImSdkWsPort
|
||||
)
|
||||
for i in ${service_port_name[*]}; do
|
||||
list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list
|
||||
for j in ${ports_array}; do
|
||||
port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}')
|
||||
if [[ ${port} -ne ${j} ]]; then
|
||||
echo -e ${YELLOW_PREFIX}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${YELLOW_PREFIX}${j}${COLOR_SUFFIX}
|
||||
echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
|
||||
exit -1
|
||||
else
|
||||
echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX}
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
#Check launched service process
|
||||
check=$(ps aux | grep -w ./${msg_transfer_name} | grep -v grep | wc -l)
|
||||
if [ $check -eq ${msg_transfer_service_num} ]; then
|
||||
echo -e ${GREEN_PREFIX}"service has been starting,belongs service is openImMsgTransfer"${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${RED_PREFIX}"openImMsgTransfer service does not start normally, num err"${COLOR_SUFFIX}
|
||||
echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX}
|
||||
exit -1
|
||||
fi
|
||||
|
||||
echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX}
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
|
||||
docker_compose_components=(
|
||||
etcd
|
||||
mongo
|
||||
mysql
|
||||
open-im-server
|
||||
redis
|
||||
kafka
|
||||
zookeeper
|
||||
)
|
||||
|
||||
component_server_count=0
|
||||
|
||||
for ((i = 0; i < ${#docker_compose_components[*]}; i++)); do
|
||||
component_server="docker-compose ps|grep -w ${docker_compose_components[$i]}|grep Up"
|
||||
count="${component_server}|wc -l"
|
||||
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
echo -e "${SKY_BLUE_PREFIX}docker-compose ${docker_compose_components[$i]} is Up!${COLOR_SUFFIX}"
|
||||
let component_server_count+=1
|
||||
else
|
||||
echo -e "${RED_PREFIX} ${docker_compose_components[$i]} start failed!${COLOR_SUFFIX}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${component_server_count} -eq 7 ]; then
|
||||
echo -e "${YELLOW_PREFIX}\ndocker-compose all services is Up!${COLOR_SUFFIX}"
|
||||
else
|
||||
echo -e "${RED_PREFIX}\nsome docker-compose services start failed,please check red logs on console ${COLOR_SUFFIX}"
|
||||
fi
|
@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#fixme This script is the total startup script
|
||||
#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array
|
||||
|
||||
#fixme Put the shell script name here
|
||||
need_to_start_server_shell=(
|
||||
start_rpc_service.sh
|
||||
msg_gateway_start.sh
|
||||
push_start.sh
|
||||
msg_transfer_start.sh
|
||||
sdk_svr_start.sh
|
||||
)
|
||||
|
||||
#fixme The 10 second delay to start the project is for the docker-compose one-click to start openIM when the infrastructure dependencies are not started
|
||||
sleep 10
|
||||
|
||||
for i in ${need_to_start_server_shell[*]}; do
|
||||
chmod +x $i
|
||||
./$i
|
||||
done
|
||||
|
||||
#fixme prevents the openIM service exit after execution in the docker container
|
||||
tail -f /dev/null
|
@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#input:[10023,2323,3434]
|
||||
#output:10023 2323 3434
|
||||
list_to_string(){
|
||||
ports_list=$*
|
||||
sub_s1=`echo $ports_list | sed 's/ //g'`
|
||||
sub_s2=${sub_s1//,/ }
|
||||
sub_s3=${sub_s2#*[}
|
||||
sub_s4=${sub_s3%]*}
|
||||
ports_array=$sub_s4
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#Include shell font styles and some basic information
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
list1=$(cat $config_path | grep openImOnlineRelayPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
rpc_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
ws_ports=($ports_array)
|
||||
if [ ${#rpc_ports[@]} -ne ${#ws_ports[@]} ]; then
|
||||
|
||||
echo -e ${RED_PREFIX}"ws_ports does not match push_rpc_ports in quantity!!!"${COLOR_SUFFIX}
|
||||
exit 0
|
||||
|
||||
fi
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${msg_gateway_binary_root}
|
||||
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
|
||||
nohup ./${msg_gateway_name} -rpc_port ${rpc_ports[$i]} -ws_port ${ws_ports[$i]} >>../logs/openIM.log 2>&1 &
|
||||
done
|
||||
|
||||
#Check launched service process
|
||||
sleep 3
|
||||
check=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | wc -l)
|
||||
allPorts=""
|
||||
if [ $check -ge 1 ]; then
|
||||
allNewPid=$(ps aux | grep -w ./${msg_gateway_name} | grep -v grep | awk '{print $2}')
|
||||
for i in $allNewPid; do
|
||||
ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
|
||||
allPorts=${allPorts}"$ports "
|
||||
done
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS"${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${YELLOW_PREFIX}${msg_gateway_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
|
||||
fi
|
@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#Include shell font styles and some basic information
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
|
||||
|
||||
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l`
|
||||
if [ $check -ge 1 ]
|
||||
then
|
||||
oldPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'`
|
||||
kill -9 $oldPid
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
|
||||
cd ${msg_transfer_binary_root}
|
||||
for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
|
||||
nohup ./${msg_transfer_name} >>../logs/openIM.log 2>&1 &
|
||||
done
|
||||
|
||||
#Check launched service process
|
||||
check=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep| wc -l`
|
||||
if [ $check -ge 1 ]
|
||||
then
|
||||
newPid=`ps aux | grep -w ./${msg_transfer_name} | grep -v grep|awk '{print $2}'`
|
||||
allPorts=""
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${YELLOW_PREFIX}${msg_transfer_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
|
||||
fi
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
#define database attributes
|
||||
address=$(cat $config_path | grep -w dbMysqlAddress)
|
||||
list_to_string ${address}
|
||||
hostAndPort=($ports_array)
|
||||
DATABASE_HOST=$(echo $hostAndPort | awk -F '[:]' '{print $1}')
|
||||
DATABASE_PORT=$(echo $hostAndPort | awk -F '[:]' '{print $NF}')
|
||||
DATABASE_USERNAME=$(cat $config_path | grep -w dbMysqlUserName | awk -F '[:]' '{print $NF}')
|
||||
DATABASE_PWD=`eval echo $(cat $config_path | grep -w dbMysqlPassword | awk -F '[:]' '{print $NF}')`
|
||||
DATABASE_NAME=$(cat $config_path | grep -w dbMysqlDatabaseName | awk -F '[:]' '{print $NF}')
|
||||
SQL_FILE="../config/mysql_sql_file/openIM.sql"
|
||||
|
||||
|
||||
create_data_sql="create database IF NOT EXISTS $DATABASE_NAME"
|
||||
set_character_code_sql="alter database $DATABASE_NAME character set utf8mb4 collate utf8mb4_general_ci"
|
||||
|
||||
echo -e "${SKY_BLUE_PREFIX}start to create database.....$COLOR_SUFFIX"
|
||||
mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$create_data_sql"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${SKY_BLUE_PREFIX}create database ${DATABASE_NAME} successfully$COLOR_SUFFIX"
|
||||
mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -e "$set_character_code_sql"
|
||||
else
|
||||
echo -e "${RED_PREFIX}create database failed or exists the database$COLOR_SUFFIX\n"
|
||||
fi
|
||||
|
||||
echo -e "${SKY_BLUE_PREFIX}start to source openIM.sql .....$COLOR_SUFFIX"
|
||||
mysql -h $DATABASE_HOST -P $DATABASE_PORT -u $DATABASE_USERNAME -p$DATABASE_PWD -D $DATABASE_NAME <$SQL_FILE
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${SKY_BLUE_PREFIX}source openIM.sql successfully$COLOR_SUFFIX"
|
||||
else
|
||||
echo -e "${RED_PREFIX}source openIM.sql failed$COLOR_SUFFIX\n"
|
||||
fi
|
@ -1,63 +0,0 @@
|
||||
#Don't put the space between "="
|
||||
msg_gateway_name="open_im_msg_gateway"
|
||||
msg_gateway_binary_root="../bin/"
|
||||
msg_gateway_source_root="../src/msg_gateway/"
|
||||
|
||||
msg_name="open_im_msg"
|
||||
msg_binary_root="../bin/"
|
||||
msg_source_root="../src/rpc/chat/"
|
||||
|
||||
push_name="open_im_push"
|
||||
push_binary_root="../bin/"
|
||||
push_source_root="../src/push/"
|
||||
|
||||
|
||||
|
||||
msg_transfer_name="open_im_msg_transfer"
|
||||
msg_transfer_binary_root="../bin/"
|
||||
msg_transfer_source_root="../src/msg_transfer/"
|
||||
msg_transfer_service_num=2
|
||||
|
||||
|
||||
sdk_server_name="open_im_sdk_server"
|
||||
sdk_server_binary_root="../bin/"
|
||||
sdk_server_source_root="../src/Open-IM-SDK-Core/"
|
||||
|
||||
|
||||
#Global configuration file default dir
|
||||
config_path="../config/config.yaml"
|
||||
|
||||
#servicefile dir path
|
||||
service_source_root=(
|
||||
#api service file
|
||||
../src/api/
|
||||
#rpc service file
|
||||
../src/rpc/user/
|
||||
../src/rpc/friend/
|
||||
../src/rpc/group/
|
||||
../src/rpc/auth/
|
||||
${msg_gateway_source_root}
|
||||
${msg_transfer_source_root}
|
||||
${msg_source_root}
|
||||
${push_source_root}
|
||||
${sdk_server_source_root}
|
||||
)
|
||||
#service filename
|
||||
service_names=(
|
||||
#api service filename
|
||||
open_im_api
|
||||
#rpc service filename
|
||||
open_im_user
|
||||
open_im_friend
|
||||
open_im_group
|
||||
open_im_auth
|
||||
${msg_gateway_name}
|
||||
${msg_transfer_name}
|
||||
${msg_name}
|
||||
${push_name}
|
||||
${sdk_server_name}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#Include shell font styles and some basic information
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
|
||||
|
||||
|
||||
list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
rpc_ports=($ports_array)
|
||||
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}')
|
||||
kill -9 $oldPid
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${push_binary_root}
|
||||
|
||||
for ((i = 0; i < ${#rpc_ports[@]}; i++)); do
|
||||
nohup ./${push_name} -port ${rpc_ports[$i]} >>../logs/openIM.log 2>&1 &
|
||||
done
|
||||
|
||||
sleep 3
|
||||
#Check launched service process
|
||||
check=$(ps aux | grep -w ./${push_name} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
newPid=$(ps aux | grep -w ./${push_name} | grep -v grep | awk '{print $2}')
|
||||
ports=$(netstat -netulp | grep -w ${newPid} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
|
||||
allPorts=""
|
||||
|
||||
for i in $ports; do
|
||||
allPorts=${allPorts}"$i "
|
||||
done
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${newPid}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX}
|
||||
fi
|
@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#Include shell font styles and some basic information
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
source ./function.sh
|
||||
list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}')
|
||||
list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}')
|
||||
list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}')
|
||||
list_to_string $list1
|
||||
api_ports=($ports_array)
|
||||
list_to_string $list2
|
||||
ws_ports=($ports_array)
|
||||
list_to_string $list3
|
||||
sdk_ws_ports=($ports_array)
|
||||
|
||||
|
||||
|
||||
|
||||
#Check if the service exists
|
||||
#If it is exists,kill this process
|
||||
check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l)
|
||||
if [ $check -ge 1 ]; then
|
||||
oldPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}')
|
||||
kill -9 ${oldPid}
|
||||
fi
|
||||
#Waiting port recycling
|
||||
sleep 1
|
||||
cd ${sdk_server_binary_root}
|
||||
nohup ./${sdk_server_name} -openIM_api_port ${api_ports[0]} -openIM_ws_port ${ws_ports[0]} -sdk_ws_port ${sdk_ws_ports[0]} >>../logs/openIM.log 2>&1 &
|
||||
|
||||
#Check launched service process
|
||||
sleep 3
|
||||
check=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | wc -l)
|
||||
allPorts=""
|
||||
if [ $check -ge 1 ]; then
|
||||
allNewPid=$(ps aux | grep -w ./${sdk_server_name} | grep -v grep | awk '{print $2}')
|
||||
for i in $allNewPid; do
|
||||
ports=$(netstat -netulp | grep -w ${i} | awk '{print $4}' | awk -F '[:]' '{print $NF}')
|
||||
allPorts=${allPorts}"$ports "
|
||||
done
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE START SUCCESS "${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allNewPid}${COLOR_SUFFIX}
|
||||
echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${YELLOW_PREFIX}${allPorts}${COLOR_SUFFIX}
|
||||
else
|
||||
echo -e ${YELLOW_PREFIX}${sdk_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR PLEASE CHECK openIM.log"${COLOR_SUFFIX}
|
||||
fi
|
@ -1 +1 @@
|
||||
Subproject commit 3d956a1a40024f0a5f4959d6e46f6f503a1618ce
|
||||
Subproject commit 17e4fc51ce877ab4d146865cc094bfbcc5abb021
|
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#fixme This script is the total startup script
|
||||
#fixme The full name of the shell script that needs to be started is placed in the need_to_start_server_shell array
|
||||
|
||||
#fixme Put the shell script name here
|
||||
need_to_start_server_shell=(
|
||||
start_rpc_service.sh
|
||||
msg_gateway_start.sh
|
||||
push_start.sh
|
||||
msg_transfer_start.sh
|
||||
sdk_svr_start.sh
|
||||
)
|
||||
|
||||
for i in ${need_to_start_server_shell[*]}; do
|
||||
chmod +x $i
|
||||
./$i
|
||||
done
|
||||
|
@ -1,59 +0,0 @@
|
||||
#!/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}
|
||||
)
|
||||
|
||||
#service config port name
|
||||
service_port_name=(
|
||||
#api port name
|
||||
openImApiPort
|
||||
#rpc port name
|
||||
openImUserPort
|
||||
openImFriendPort
|
||||
openImGroupPort
|
||||
openImAuthPort
|
||||
openImOfflineMessagePort
|
||||
|
||||
)
|
||||
|
||||
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}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service has been started,pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing the service ${service_filename[$i]} pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
sleep 0.5
|
||||
fi
|
||||
cd ../bin && echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} service is starting${COLOR_SUFFIX}"
|
||||
#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}
|
||||
#Start related rpc services based on the number of ports
|
||||
for j in ${ports_array}; do
|
||||
echo -e "${SKY_BLUE_PREFIX}${service_filename[$i]} Service is starting,port number:$j $COLOR_SUFFIX"
|
||||
#Start the service in the background
|
||||
# ./${service_filename[$i]} -port $j &
|
||||
nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 &
|
||||
sleep 1
|
||||
pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1"
|
||||
echo -e "${RED_PREFIX}${service_filename[$i]} Service is started,port number:$j pid:$(eval $pid)$COLOR_SUFFIX"
|
||||
done
|
||||
done
|
@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#fixme This script is to stop the service
|
||||
|
||||
source ./style_info.cfg
|
||||
source ./path_info.cfg
|
||||
|
||||
|
||||
for i in ${service_names[*]}; do
|
||||
#Check whether the service exists
|
||||
name="ps -aux |grep -w $i |grep -v grep"
|
||||
count="${name}| wc -l"
|
||||
if [ $(eval ${count}) -gt 0 ]; then
|
||||
pid="${name}| awk '{print \$2}'"
|
||||
echo -e "${SKY_BLUE_PREFIX}Killing service:$i pid:$(eval $pid)${COLOR_SUFFIX}"
|
||||
#kill the service that existed
|
||||
kill -9 $(eval $pid)
|
||||
echo -e "${SKY_BLUE_PREFIX}service:$i was killed ${COLOR_SUFFIX}"
|
||||
fi
|
||||
done
|
@ -1,9 +0,0 @@
|
||||
#Shell font formatting information
|
||||
COLOR_SUFFIX="\033[0m"
|
||||
BLACK_PREFIX="\033[30m"
|
||||
RED_PREFIX="\033[31m"
|
||||
GREEN_PREFIX="\033[32m"
|
||||
YELLOW_PREFIX="\033[33m"
|
||||
BLUE_PREFIX="\033[34m"
|
||||
PURPLE_PREFIX="\033[35m"
|
||||
SKY_BLUE_PREFIX="\033[36m"
|
Loading…
Reference in new issue