diff --git a/build_all_service.sh b/build_all_service.sh deleted file mode 100644 index 6f563b6f6..000000000 --- a/build_all_service.sh +++ /dev/null @@ -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 diff --git a/check_all.sh b/check_all.sh deleted file mode 100644 index b984cc10a..000000000 --- a/check_all.sh +++ /dev/null @@ -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} diff --git a/docker_check_service.sh b/docker_check_service.sh deleted file mode 100644 index c9fd54ec8..000000000 --- a/docker_check_service.sh +++ /dev/null @@ -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 diff --git a/docker_start_all.sh b/docker_start_all.sh deleted file mode 100644 index fce59c41a..000000000 --- a/docker_start_all.sh +++ /dev/null @@ -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 diff --git a/function.sh b/function.sh deleted file mode 100644 index b57373c72..000000000 --- a/function.sh +++ /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 -} \ No newline at end of file diff --git a/msg_gateway_start.sh b/msg_gateway_start.sh deleted file mode 100644 index c21d335ca..000000000 --- a/msg_gateway_start.sh +++ /dev/null @@ -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 diff --git a/msg_transfer_start.sh b/msg_transfer_start.sh deleted file mode 100644 index 0b645596c..000000000 --- a/msg_transfer_start.sh +++ /dev/null @@ -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 diff --git a/mysql_database_init.sh b/mysql_database_init.sh deleted file mode 100644 index f8e4caa59..000000000 --- a/mysql_database_init.sh +++ /dev/null @@ -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 diff --git a/path_info.cfg b/path_info.cfg deleted file mode 100644 index 4529c93d6..000000000 --- a/path_info.cfg +++ /dev/null @@ -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} -) - - - - diff --git a/push_start.sh b/push_start.sh deleted file mode 100644 index 51ec1d6ba..000000000 --- a/push_start.sh +++ /dev/null @@ -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 diff --git a/script/build_all_service.sh b/script/build_all_service.sh index 6f563b6f6..07a34bb08 100644 --- a/script/build_all_service.sh +++ b/script/build_all_service.sh @@ -1,30 +1,30 @@ -#!/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 +#!/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 diff --git a/script/check_all.sh b/script/check_all.sh index b984cc10a..3c57577c4 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -1,43 +1,43 @@ -#!/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} +#!/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} diff --git a/script/docker_check_service.sh b/script/docker_check_service.sh index c9fd54ec8..e380cb3fb 100644 --- a/script/docker_check_service.sh +++ b/script/docker_check_service.sh @@ -1,33 +1,33 @@ -#!/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 +#!/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 diff --git a/script/docker_start_all.sh b/script/docker_start_all.sh index fce59c41a..740b88e85 100644 --- a/script/docker_start_all.sh +++ b/script/docker_start_all.sh @@ -1,23 +1,23 @@ -#!/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 +#!/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 diff --git a/script/function.sh b/script/function.sh index b57373c72..0deb52b38 100644 --- a/script/function.sh +++ b/script/function.sh @@ -1,11 +1,11 @@ -#!/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 +#!/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 } \ No newline at end of file diff --git a/script/msg_gateway_start.sh b/script/msg_gateway_start.sh index c21d335ca..1df53cfdd 100644 --- a/script/msg_gateway_start.sh +++ b/script/msg_gateway_start.sh @@ -1,48 +1,48 @@ -#!/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 +#!/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 diff --git a/script/msg_transfer_start.sh b/script/msg_transfer_start.sh index 0b645596c..4d7fb96cd 100644 --- a/script/msg_transfer_start.sh +++ b/script/msg_transfer_start.sh @@ -1,36 +1,36 @@ -#!/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 +#!/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 diff --git a/script/mysql_database_init.sh b/script/mysql_database_init.sh index f8e4caa59..2a5135e8e 100644 --- a/script/mysql_database_init.sh +++ b/script/mysql_database_init.sh @@ -1,38 +1,38 @@ -#!/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 +#!/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 diff --git a/script/path_info.cfg b/script/path_info.cfg index 4529c93d6..f67e017c2 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -1,63 +1,63 @@ -#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} -) - - - - +#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} +) + + + + diff --git a/script/push_start.sh b/script/push_start.sh index 51ec1d6ba..8b2a47896 100644 --- a/script/push_start.sh +++ b/script/push_start.sh @@ -1,45 +1,45 @@ -#!/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 +#!/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 diff --git a/script/sdk_svr_start.sh b/script/sdk_svr_start.sh index 4d6af3999..97c694233 100644 --- a/script/sdk_svr_start.sh +++ b/script/sdk_svr_start.sh @@ -1,47 +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 -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 +#!/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 diff --git a/script/start_all.sh b/script/start_all.sh index 9990cb6c8..43a02b34d 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -1,18 +1,18 @@ -#!/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 - +#!/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 + diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index 6307ca1c0..74f00a3f4 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -1,59 +1,59 @@ -#!/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 +#!/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 diff --git a/script/stop_all.sh b/script/stop_all.sh index ef7237ab5..2e1e119c1 100644 --- a/script/stop_all.sh +++ b/script/stop_all.sh @@ -1,19 +1,19 @@ -#!/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 +#!/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 diff --git a/script/style_info.cfg b/script/style_info.cfg index 92cc5da49..ff28dcb88 100644 --- a/script/style_info.cfg +++ b/script/style_info.cfg @@ -1,9 +1,9 @@ -#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" +#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" diff --git a/sdk_svr_start.sh b/sdk_svr_start.sh deleted file mode 100644 index 4d6af3999..000000000 --- a/sdk_svr_start.sh +++ /dev/null @@ -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 diff --git a/src/Open-IM-SDK-Core b/src/Open-IM-SDK-Core index 3d956a1a4..17e4fc51c 160000 --- a/src/Open-IM-SDK-Core +++ b/src/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 3d956a1a40024f0a5f4959d6e46f6f503a1618ce +Subproject commit 17e4fc51ce877ab4d146865cc094bfbcc5abb021 diff --git a/src/api/friend/add_friend.go b/src/api/friend/add_friend.go index 40fee7dac..c671f949a 100644 --- a/src/api/friend/add_friend.go +++ b/src/api/friend/add_friend.go @@ -41,7 +41,9 @@ func ImportFriend(c *gin.Context) { OwnerUid: params.OwnerUid, Token: c.Request.Header.Get("token"), } + log.NewInfo(params.OperationID, "ImportFriend Test start", params.UIDList, params.OwnerUid) RpcResp, err := client.ImportFriend(context.Background(), req) + //log.ErrorByKv("ImportFriend Test end", params.OperationID, "resp", RpcResp, "err", err.Error()) if err != nil { log.Error(req.Token, req.OperationID, "err=%s,ImportFriend failed", err) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed" + err.Error()}) diff --git a/start_all.sh b/start_all.sh deleted file mode 100644 index 9990cb6c8..000000000 --- a/start_all.sh +++ /dev/null @@ -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 - diff --git a/start_rpc_service.sh b/start_rpc_service.sh deleted file mode 100644 index 6307ca1c0..000000000 --- a/start_rpc_service.sh +++ /dev/null @@ -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 diff --git a/stop_all.sh b/stop_all.sh deleted file mode 100644 index ef7237ab5..000000000 --- a/stop_all.sh +++ /dev/null @@ -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 diff --git a/style_info.cfg b/style_info.cfg deleted file mode 100644 index 92cc5da49..000000000 --- a/style_info.cfg +++ /dev/null @@ -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"