提交 7f70cf6c 编写于 作者: 落凡尘.'s avatar 落凡尘.

Shell script initial commit

上级 e654e765
#!/usr/bin/env bash
source ./style_info.cfg
source ./path_info.cfg
source ./function.sh
#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
#!/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=(
auto_start_service.sh
msg_gateway_start.sh
push_start.sh
msg_transfer_start.sh
)
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
./$i
done
while [ true ]; do
sleep 60
done
#!/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 >/dev/null 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
#!/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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册