diff --git a/README-zh_CN.md b/README-zh_CN.md index 87d675c88..1cdd0a52e 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -142,7 +142,7 @@ Open-IM-Server 是一款即时通讯服务器,使用纯 Golang 开发,采用 > Open-IM 脚本提供服务编译、启动和停止脚本。有四个 Open-IM 脚本启动模块,一个是 http+rpc 服务启动模块,第二个是 WebSocket 服务启动模块,然后是 msg_transfer 模块,最后是 push 模块。 -+ path_info.cfg&&style_info.cfg&& ++ path_info.sh&&style_info.sh&& functions.sh diff --git a/README.md b/README.md index d3d880d41..e8da2ab5e 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ all services build success > Open-IM scripts provides service compilation, start, and stop scripts. There are four Open-IM scripts start modules, one is the http+rpc service start module, the second is the websocket service start module, then the msg_transfer module, and the last is the push module -- path_info.cfg&&style_info.cfg&&functions.sh +- path_info.sh&&style_info.sh&&functions.sh - Contains the path information of each module, including the path where the source code is located, the name of the service startup, the shell print font style, and some functions for processing shell strings - build_all_service.sh - Compile the module, compile all the source code of Open-IM into a binary file and put it into the bin directory diff --git a/cmd/openim-cmdutils/Makefile b/cmd/openim-cmdutils/Makefile index 9c51aee84..e78ac33f6 100644 --- a/cmd/openim-cmdutils/Makefile +++ b/cmd/openim-cmdutils/Makefile @@ -1,6 +1,6 @@ .PHONY: all build run gotool install clean help -NAME=openim_cmd_utils +NAME=openim-cmdutils BIN_DIR=../../bin/ OS:= $(or $(os),linux) diff --git a/config/config.yaml b/config/config.yaml index def91d2b5..ea6f8772d 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -274,5 +274,4 @@ prometheus: #prometheus每个服务的端口数量需要和rpcPort保持对应 conversationPrometheusPort: [ 20230 ] rtcPrometheusPort: [ 21300 ] thirdPrometheusPort: [ 21301 ] - messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] #端口数量需要和script/path_info.cfg中的msg_transfer_service_num保持一致 - + messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] #端口数量需要和script/path_info.sh中的msg_transfer_service_num保持一致 diff --git a/scripts/batch_build_all_service.sh b/scripts/batch_build_all_service.sh index 7bb75de77..f3bd791cf 100755 --- a/scripts/batch_build_all_service.sh +++ b/scripts/batch_build_all_service.sh @@ -20,8 +20,8 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "$(dirname "${BASH_SOURCE[0]}")/../scripts.sh" # Include specific functions and variables -source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.cfg" \ - "$OPENIM_ROOT/scripts/path_info.cfg" +source "$(dirname "${BASH_SOURCE[0]}")/../scripts/style_info.sh" \ + "$OPENIM_ROOT/scripts/path_info.sh" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" @@ -76,5 +76,5 @@ done echo "success_num" $success_num "service num:" ${#service_source_root[*]} if [ $success_num == ${#service_source_root[*]} ] then - echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX} + echo -e ${BACKGROUND_GREEN}"all services build success"${COLOR_SUFFIX} fi diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh index aa7713280..e291819f4 100755 --- a/scripts/batch_start_all.sh +++ b/scripts/batch_start_all.sh @@ -16,9 +16,20 @@ #fixme This scripts is the total startup scripts #fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -cd "$OPENIM_ROOT/scripts/" +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" need_to_start_server_shell=( "start_rpc_service.sh" @@ -30,13 +41,13 @@ need_to_start_server_shell=( time=$(date +"%Y-%m-%d %H:%M:%S") for _ in {1..3}; do - echo "==========================================================" >> ../logs/openIM.log 2>&1 + echo "==========================================================" >> $OPENIM_ROOT/logs/openIM.log 2>&1 done -echo "==========server start time:${time}===========" >> ../logs/openIM.log 2>&1 +echo "==========server start time:${time}===========" >> $OPENIM_ROOT/logs/openIM.log 2>&1 for _ in {1..3}; do - echo "==========================================================" >> ../logs/openIM.log 2>&1 + echo "==========================================================" >> $OPENIM_ROOT/logs/openIM.log 2>&1 done build_pid_array=() @@ -74,5 +85,5 @@ done echo "success_num" $success_num "service num:" ${#need_to_start_server_shell[*]} if [ $success_num == ${#need_to_start_server_shell[*]} ] then - echo -e ${YELLOW_PREFIX}"all services build success"${COLOR_SUFFIX} + echo -e ${BACKGROUND_GREEN}"all services build success"${COLOR_SUFFIX} fi diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh index aed63a818..fd196e48b 100755 --- a/scripts/build_all_service.sh +++ b/scripts/build_all_service.sh @@ -14,8 +14,8 @@ # limitations under the License. -source ./style_info.cfg -source ./path_info.cfg +source ./style_info.sh +source ./path_info.sh source ./function.sh echo -e "" @@ -43,8 +43,8 @@ fi OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg +source $OPENIM_ROOT/scripts/style_info.sh +source $OPENIM_ROOT/scripts/path_info.sh source $OPENIM_ROOT/scripts/function.sh cd $OPENIM_ROOT diff --git a/scripts/build_push_k8s_images.sh b/scripts/build_push_k8s_images.sh index ff9887c56..a620c7847 100755 --- a/scripts/build_push_k8s_images.sh +++ b/scripts/build_push_k8s_images.sh @@ -23,7 +23,7 @@ fi set +e echo "repository: ${repository}" -source ./path_info.cfg +source ./path_info.sh echo "start to build docker images" currentPwd=`pwd` echo ${currentPwd} diff --git a/scripts/check_all.sh b/scripts/check_all.sh index 0bcb782dd..db420dd21 100755 --- a/scripts/check_all.sh +++ b/scripts/check_all.sh @@ -13,10 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +#Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh +#Include shell font styles and some basic information +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" service_port_name=( openImWsPort @@ -37,8 +47,8 @@ for i in ${service_port_name[*]}; do for j in ${ports_array}; do port=$(ss -tunlp| grep openim | awk '{print $5}' | 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} + echo -e ${BACKGROUND_GREEN}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX} exit -1 else echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} @@ -52,7 +62,7 @@ if [ $check -eq ${msg_transfer_service_num} ]; then echo -e ${GREEN_PREFIX}"none port has been listening,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} + echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX} exit -1 fi @@ -62,8 +72,8 @@ if [ $check -ge 1 ]; then echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImCronTask"${COLOR_SUFFIX} else echo -e ${RED_PREFIX}"cron_task_name service does not start normally"${COLOR_SUFFIX} - echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX} exit -1 fi -echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} +echo -e ${BACKGROUND_GREEN}"all services launch success"${COLOR_SUFFIX} diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 8ed198cae..98e5a131c 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -29,13 +29,13 @@ need_to_start_server_shell=( sleep 10 time=`date +"%Y-%m-%d %H:%M:%S"` -echo "==========================================================">>../logs/openIM.log 2>&1 & -echo "==========================================================">>../logs/openIM.log 2>&1 & -echo "==========================================================">>../logs/openIM.log 2>&1 & -echo "==========server start time:${time}===========">>../logs/openIM.log 2>&1 & -echo "==========================================================">>../logs/openIM.log 2>&1 & -echo "==========================================================">>../logs/openIM.log 2>&1 & -echo "==========================================================">>../logs/openIM.log 2>&1 & +echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & +echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & +echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & +echo "==========server start time:${time}===========">>$OPENIM_ROOT/logs/openIM.log 2>&1 & +echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & +echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & +echo "==========================================================">>$OPENIM_ROOT/logs/openIM.log 2>&1 & for i in ${need_to_start_server_shell[*]}; do chmod +x $i ./$i diff --git a/scripts/enterprise/check_all.sh b/scripts/enterprise/check_all.sh index 8c9d3a82a..7b8a3c5da 100755 --- a/scripts/enterprise/check_all.sh +++ b/scripts/enterprise/check_all.sh @@ -14,14 +14,19 @@ # limitations under the License. #Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg -source $OPENIM_ROOT/scripts/function.sh +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh -cd "$OPENIM_ROOT/scripts/" +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" service_port_name=( openImChatApiPort @@ -37,8 +42,8 @@ for i in ${service_port_name[*]}; do for j in ${ports_array}; do port=$(ss -tunlp| grep openim | awk '{print $5}' | 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} + echo -e ${BACKGROUND_GREEN}${i}${COLOR_SUFFIX}${RED_PREFIX}" service does not start normally,not initiated port is "${COLOR_SUFFIX}${BACKGROUND_GREEN}${j}${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"please check $OPENIM_ROOT/logs/openIM.log "${COLOR_SUFFIX} exit -1 else echo -e ${j}${GREEN_PREFIX}" port has been listening,belongs service is "${i}${COLOR_SUFFIX} diff --git a/scripts/env_check.sh b/scripts/env_check.sh index c6cfaf4bb..8c84567b7 100755 --- a/scripts/env_check.sh +++ b/scripts/env_check.sh @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -source ./style_info.cfg +source ./style_info.sh echo -e "check time synchronize.................................." t=`curl http://time.akamai.com/?iso -s` diff --git a/scripts/function.sh b/scripts/function.sh index e2dc96a25..e351c1ddb 100755 --- a/scripts/function.sh +++ b/scripts/function.sh @@ -13,17 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -#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 +# 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 # 将处理后的字符串赋值给变量 ports_array +} + +# 函数功能:去除字符串中的空格 +remove_space() { + value=$* # 获取传入的参数 + result=$(echo $value | sed 's/ //g') # 去除空格 } -remove_space(){ - value=$* - result=`echo $value | sed 's/ //g'` -} \ No newline at end of file diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push index 9087e0cb9..2ed9736be 100644 --- a/scripts/githooks/pre-push +++ b/scripts/githooks/pre-push @@ -45,7 +45,7 @@ COLOR_SUFFIX="\033[0m" BLACK_PREFIX="\033[30m" RED_PREFIX="\033[31m" GREEN_PREFIX="\033[32m" -YELLOW_PREFIX="\033[33m" +BACKGROUND_GREEN="\033[33m" BLUE_PREFIX="\033[34m" PURPLE_PREFIX="\033[35m" SKY_BLUE_PREFIX="\033[36m" @@ -92,9 +92,9 @@ added_files=$(grep -c '^A' <<< "$file_list") modified_files=$(grep -c '^M' <<< "$file_list") deleted_files=$(grep -c '^D' <<< "$file_list") -print_color "Added Files: ${added_files}" "${YELLOW_PREFIX}" -print_color "Modified Files: ${modified_files}" "${YELLOW_PREFIX}" -print_color "Deleted Files: ${deleted_files}" "${YELLOW_PREFIX}" +print_color "Added Files: ${added_files}" "${BACKGROUND_GREEN}" +print_color "Modified Files: ${modified_files}" "${BACKGROUND_GREEN}" +print_color "Deleted Files: ${deleted_files}" "${BACKGROUND_GREEN}" # #printMessage "Running the Flutter analyzer" diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh index 62a8479c9..7df840b21 100755 --- a/scripts/msg_gateway_start.sh +++ b/scripts/msg_gateway_start.sh @@ -14,12 +14,19 @@ # limitations under the License. #Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg -source $OPENIM_ROOT/scripts/function.sh +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" @@ -53,8 +60,8 @@ fi sleep 1 cd ${msg_gateway_binary_root} for ((i = 0; i < ${#ws_ports[@]}; i++)); do - echo "==========================start msg_gateway server===========================">>../logs/openIM.log - nohup ./${openim-msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 & + echo "==========================start msg_gateway server===========================">>$OPENIM_ROOT/logs/openIM.log + nohup ./${openim-msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 & done #Check launched service process @@ -68,9 +75,9 @@ if [ $check -ge 1 ]; then 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}${openim-msggateway}${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} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allNewPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${YELLOW_PREFIX}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + echo -e ${BACKGROUND_GREEN}${openim-msggateway}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} fi diff --git a/scripts/msg_transfer_start.sh b/scripts/msg_transfer_start.sh index 50c01cb9d..b038d125a 100755 --- a/scripts/msg_transfer_start.sh +++ b/scripts/msg_transfer_start.sh @@ -14,12 +14,19 @@ # limitations under the License. #Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg -source $OPENIM_ROOT/scripts/function.sh +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" @@ -49,8 +56,8 @@ for ((i = 0; i < ${msg_transfer_service_num}; i++)); do if [ $prome_port != "" ]; then cmd="$cmd --prometheus_port $prome_port" fi - echo "==========================start msg_transfer server===========================">>../logs/openIM.log - $cmd >>../logs/openIM.log 2>&1 & + echo "==========================start msg_transfer server===========================">>$OPENIM_ROOT/logs/openIM.log + $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 & done #Check launched service process @@ -60,9 +67,9 @@ then newPid=`ps aux | grep -w ./${openim-msgtransfer} | 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}${openim-msgtransfer}${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} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${YELLOW_PREFIX}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + echo -e ${BACKGROUND_GREEN}${openim-msgtransfer}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} fi diff --git a/scripts/path_info.cfg b/scripts/path_info.sh similarity index 73% rename from scripts/path_info.cfg rename to scripts/path_info.sh index 57f328a47..0edc0b5b2 100755 --- a/scripts/path_info.cfg +++ b/scripts/path_info.sh @@ -1,22 +1,17 @@ +#!/usr/bin/env bash # Determine the architecture and version architecture=$(uname -m) version=$(uname -s | tr '[:upper:]' '[:lower:]') #Include shell font styles and some basic information SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $SCRIPTS_ROOT/style_info.cfg -source $SCRIPTS_ROOT/path_info.cfg -source $SCRIPTS_ROOT/function.sh +source $SCRIPTS_ROOT/style_info.sh cd $SCRIPTS_ROOT -echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" -echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" -echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}" - # Define the supported architectures and corresponding bin directories declare -A supported_architectures=( ["linux-amd64"]="_output/bin/platforms/linux/amd64" @@ -47,29 +42,28 @@ echo "================> BIN_DIR: $OPENIM_ROOT/$BIN_DIR" # Don't put the space between "=" openim_msggateway="openim-msggateway" msg_gateway_binary_root="$OPENIM_ROOT/$BIN_DIR" -msg_gateway_source_root="../cmd/msggateway/" +msg_gateway_source_root="$OPENIM_ROOT/cmd/msggateway/" msg_name="openim-rpc-msg" msg_binary_root="$OPENIM_ROOT/$BIN_DIR" -msg_source_root="../cmd/openim-rpc/msg/" +msg_source_root="$OPENIM_ROOT/cmd/openim-rpc/msg/" push_name="openim-push" push_binary_root="$OPENIM_ROOT/$BIN_DIR" -push_source_root="../cmd/push/" +push_source_root="$OPENIM_ROOT/cmd/push/" openim_msgtransfer="openim-rpc-msg_transfer" msg_transfer_binary_root="$OPENIM_ROOT/$BIN_DIR" -msg_transfer_source_root="$OPENIM_ROOT/cmd/msgtransfer/" +msg_transfer_source_root="$OPENIM_ROOT/cmd/openim-msgtransfer/" msg_transfer_service_num=4 cron_task_name="openim-crontask" cron_task_binary_root="$OPENIM_ROOT/$BIN_DIR" -cron_task_source_root="$OPENIM_ROOT/cmd/crontask/" - +cron_task_source_root="$OPENIM_ROOT/cmd/openim-crontask/" -cmd_utils_name="openim_cmd_utils" +cmd_utils_name="openim-cmdutils" cmd_utils_binary_root="$OPENIM_ROOT/$BIN_DIR" -cmd_utils_source_root="$OPENIM_ROOT/cmd/cmduitls/" +cmd_utils_source_root="$OPENIM_ROOT/cmd/openim-cmdutils/" # Global configuration file default dir config_path="$OPENIM_ROOT/config/config.yaml" @@ -77,15 +71,15 @@ config_path="$OPENIM_ROOT/config/config.yaml" # servicefile dir path service_source_root=( # api service file - "../cmd/api/" + "$OPENIM_ROOT/cmd/api/" # rpc service file - "../cmd/openim-rpc/openim-rpc-user/" - "../cmd/openim-rpc/openim-rpc-friend/" - "../cmd/openim-rpc/openim-rpc-group/" - "../cmd/openim-rpc/openim-rpc-auth/" - "../cmd/openim-rpc/openim-rpc-conversation/" - "../cmd/openim-rpc/openim-rpc-third/" - "../cmd/openim-crontask" + "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-user/" + "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-friend/" + "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-group/" + "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-auth/" + "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-conversation/" + "$OPENIM_ROOT/cmd/openim-rpc/openim-rpc-third/" + "$OPENIM_ROOT/cmd/openim-crontask" "${msg_gateway_source_root}" "${msg_transfer_source_root}" "${msg_source_root}" diff --git a/scripts/push_start.sh b/scripts/push_start.sh index 204f710e7..55ac28bb3 100755 --- a/scripts/push_start.sh +++ b/scripts/push_start.sh @@ -14,12 +14,19 @@ # limitations under the License. #Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg -source $OPENIM_ROOT/scripts/function.sh +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" @@ -46,8 +53,8 @@ sleep 1 cd ${push_binary_root} for ((i = 0; i < ${#rpc_ports[@]}; i++)); do - echo "==========================start push server===========================">>../logs/openIM.log - nohup ./${push_name} --port ${rpc_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 & + echo "==========================start push server===========================">>$OPENIM_ROOT/logs/openIM.log + nohup ./${push_name} --port ${rpc_ports[$i]} --prometheus_port ${prome_ports[$i]} >>$OPENIM_ROOT/logs/openIM.log 2>&1 & done sleep 3 @@ -62,9 +69,9 @@ if [ $check -ge 1 ]; then 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} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${YELLOW_PREFIX}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + echo -e ${BACKGROUND_GREEN}${push_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} fi diff --git a/scripts/start_all.sh b/scripts/start_all.sh index 44c613479..976320dad 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -21,15 +21,15 @@ SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. #Include shell font styles and some basic information -source $SCRIPTS_ROOT/style_info.cfg -source $SCRIPTS_ROOT/path_info.cfg +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh source $SCRIPTS_ROOT/function.sh cd $SCRIPTS_ROOT -echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" -echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" -echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" @@ -65,7 +65,7 @@ for i in ${need_to_start_server_shell[*]}; do echo -e "" # Print script execution message - echo -e "=========> ${YELLOW_PREFIX}Executing ${i}...${COLOR_SUFFIX}" + echo -e "=========> ${BACKGROUND_GREEN}Executing ${i}...${COLOR_SUFFIX}" echo -e "" ./$i diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh index c7ce4e451..1fccedcf2 100755 --- a/scripts/start_cron.sh +++ b/scripts/start_cron.sh @@ -14,19 +14,24 @@ # limitations under the License. #Include shell font styles and some basic information +SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg -source $OPENIM_ROOT/scripts/function.sh +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh +source $SCRIPTS_ROOT/function.sh + +cd $SCRIPTS_ROOT + +echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" sdk_db_dir="$OPENIM_ROOT/sdk/db/" -cd "$OPENIM_ROOT/scripts/" - #Check if the service exists #If it is exists,kill this process check=`ps aux | grep -w ./${cron_task_name} | grep -v grep| wc -l` @@ -40,8 +45,8 @@ sleep 1 cd ${cron_task_binary_root} #for ((i = 0; i < ${cron_task_service_num}; i++)); do - echo "==========================start cron_task process===========================">>../logs/openIM.log -nohup ./${cron_task_name} >>../logs/openIM.log 2>&1 & + echo "==========================start cron_task process===========================">>$OPENIM_ROOT/logs/openIM.log +nohup ./${cron_task_name} >>$OPENIM_ROOT/logs/openIM.log 2>&1 & #done #Check launched service process @@ -51,9 +56,9 @@ then newPid=`ps aux | grep -w ./${cron_task_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}${cron_task_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} + echo -e ${SKY_BLUE_PREFIX}"SERVICE_NAME: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"PID: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${newPid}${COLOR_SUFFIX} + echo -e ${SKY_BLUE_PREFIX}"LISTENING_PORT: "${COLOR_SUFFIX}${BACKGROUND_GREEN}${allPorts}${COLOR_SUFFIX} else - echo -e ${YELLOW_PREFIX}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} + echo -e ${BACKGROUND_GREEN}${cron_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} fi diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh index 2d0e70f63..1cafd2b1c 100755 --- a/scripts/start_rpc_service.sh +++ b/scripts/start_rpc_service.sh @@ -15,25 +15,22 @@ #Include shell font styles and some basic information SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/.. +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $SCRIPTS_ROOT/style_info.cfg -source $SCRIPTS_ROOT/path_info.cfg -source $SCRIPTS_ROOT/function.sh +source $SCRIPTS_ROOT/style_info.sh +source $SCRIPTS_ROOT/path_info.sh cd $SCRIPTS_ROOT -echo -e "${BACKGROUND_YELLOW}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" -echo -e "${BACKGROUND_YELLOW}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" -echo -e "${BACKGROUND_YELLOW}=======>pwd=$PWD${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}" +echo -e "${BACKGROUND_GREEN}${CYAN_PREFIX}=======>pwd=$PWD${COLOR_SUFFIX}" bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" sdk_db_dir="$OPENIM_ROOT/sdk/db/" -cd $OPENIM_ROOT - #service filename service_filename=( #api @@ -88,8 +85,9 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do kill -9 $(eval $pid) sleep 0.5 fi - cd $ - #Get the rpc port in the configuration file + cd $OPENIM_ROOT + cd $BIN_DIR + # 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} service_ports=($ports_array) @@ -109,8 +107,8 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do cmd="./${service_filename[$i]} --port ${service_ports[$j]}" fi echo $cmd - echo "=====================start ${service_filename[$i]}======================">>../logs/openIM.log - nohup $cmd >>../logs/openIM.log 2>&1 & + echo "=====================start ${service_filename[$i]}======================">>$OPENIM_ROOT/logs/openIM.log + nohup $cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 & sleep 1 pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX" diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh index 7bec5b53f..4e3537ea7 100755 --- a/scripts/stop_all.sh +++ b/scripts/stop_all.sh @@ -17,8 +17,8 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. #Include shell font styles and some basic information -source $OPENIM_ROOT/scripts/style_info.cfg -source $OPENIM_ROOT/scripts/path_info.cfg +source $OPENIM_ROOT/scripts/style_info.sh +source $OPENIM_ROOT/scripts/path_info.sh source $OPENIM_ROOT/scripts/function.sh bin_dir="$BIN_DIR" diff --git a/scripts/style_info.cfg b/scripts/style_info.sh similarity index 98% rename from scripts/style_info.cfg rename to scripts/style_info.sh index f0b6a32db..631f8a5f1 100755 --- a/scripts/style_info.cfg +++ b/scripts/style_info.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + COLOR_SUFFIX="\033[0m" # End all colors and special effects BLACK_PREFIX="\033[30m" # Black prefix