From 1d4b47f5e65747a137bc7be5c11a23e83a594830 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 1 Dec 2021 15:01:15 +0800 Subject: [PATCH] script update --- script/check_all.sh | 7 ++++++ script/demo_svr_start.sh | 47 ++++++++++++++++++++++++++++++++++++++++ script/path_info.cfg | 6 +++++ script/start_all.sh | 1 + 4 files changed, 61 insertions(+) create mode 100644 script/demo_svr_start.sh diff --git a/script/check_all.sh b/script/check_all.sh index 9e6d45db4..0c7313743 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -14,8 +14,15 @@ service_port_name=( openImPushPort openImWsPort openImSdkWsPort + openImDemoPort ) +switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}') for i in ${service_port_name[*]}; do + if [ ${switch} != "true" ]; then + if [ ${i} == "openImDemoPort"]; then + continue + fi + fi list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') list_to_string $list for j in ${ports_array}; do diff --git a/script/demo_svr_start.sh b/script/demo_svr_start.sh new file mode 100644 index 000000000..55aaa88b1 --- /dev/null +++ b/script/demo_svr_start.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +#Include shell font styles and some basic information +source ./style_info.cfg +source ./path_info.cfg +source ./function.sh +switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}') +if [ ${switch} != "true" ]; then + echo -e ${YELLOW_PREFIX}" demo service switch is false not start demo "${COLOR_SUFFIX} + exit 0 +fi +list1=$(cat $config_path | grep openImDemoPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +api_ports=($ports_array) + +#Check if the service exists +#If it is exists,kill this process +check=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + oldPid=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | awk '{print $2}') + kill -9 $oldPid +fi +#Waiting port recycling +sleep 1 +cd ${demo_server_binary_root} + +for ((i = 0; i < ${#api_ports[@]}; i++)); do + nohup ./${demo_server_name} -port ${api_ports[$i]} >>../logs/openIM.log 2>&1 & +done + +sleep 3 +#Check launched service process +check=$(ps aux | grep -w ./${demo_server_name} | grep -v grep | wc -l) +if [ $check -ge 1 ]; then + newPid=$(ps aux | grep -w ./${demo_server_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}${demo_server_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}${demo_server_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} +fi diff --git a/script/path_info.cfg b/script/path_info.cfg index b97588e61..ea9fa76e9 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -27,6 +27,10 @@ sdk_server_name="open_im_sdk_server" sdk_server_binary_root="../bin/" sdk_server_source_root="../cmd/Open-IM-SDK-Core/" +demo_server_name="open_im_demo" +demo_server_binary_root="../bin/" +demo_server_source_root="../cmd/open_im_demo/" + #Global configuration file default dir config_path="../config/config.yaml" @@ -46,6 +50,7 @@ service_source_root=( ${push_source_root} ${sdk_server_source_root} ${timer_task_source_root} + ${demo_server_source_root} ) #service filename service_names=( @@ -62,6 +67,7 @@ service_names=( ${push_name} ${sdk_server_name} ${timer_task_name} + ${demo_server_name} ) diff --git a/script/start_all.sh b/script/start_all.sh index 956bc0d51..dd9420adc 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -10,6 +10,7 @@ need_to_start_server_shell=( msg_transfer_start.sh sdk_svr_start.sh timer_start.sh + demo_svr_start.sh ) for i in ${need_to_start_server_shell[*]}; do