From d7ce413fc39c1e1d17b15f2737e7fcdfe84733ed Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jun 2023 23:29:18 +0800 Subject: [PATCH] feat: Initialize the script file Signed-off-by: unknown --- install_im_server.sh | 19 -------- script/.env | 3 -- script/batch_start_all.sh | 1 - script/build_push_k8s_images.sh | 32 +++++++++++++ script/check_all.sh | 34 +++++--------- script/demo_svr_start.sh | 47 ------------------- script/docker_check_service.sh | 6 +-- script/docker_start_all.sh | 1 - script/enterprise/check_all.sh | 2 +- script/enterprise/path_info.cfg | 2 +- script/init_pwd.sh | 11 +++++ script/mongo-init.sh | 12 +++++ script/msg_gateway_start.sh | 8 +++- script/msg_transfer_start.sh | 12 ++++- script/mysql_database_init.sh | 38 ---------------- script/path_info.cfg | 80 ++++++++++++++++++--------------- script/push_start.sh | 6 ++- script/sdk_svr_start.sh | 14 +++--- script/start_all.sh | 4 +- script/start_cron.sh | 3 +- script/start_rpc_service.sh | 49 +++++++++++++------- script/timer_start.sh | 35 --------------- 22 files changed, 178 insertions(+), 241 deletions(-) delete mode 100644 install_im_server.sh delete mode 100644 script/.env create mode 100644 script/build_push_k8s_images.sh delete mode 100644 script/demo_svr_start.sh create mode 100644 script/init_pwd.sh create mode 100644 script/mongo-init.sh delete mode 100644 script/mysql_database_init.sh delete mode 100644 script/timer_start.sh diff --git a/install_im_server.sh b/install_im_server.sh deleted file mode 100644 index ea641d0f8..000000000 --- a/install_im_server.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -internet_ip=`curl ifconfig.me -s` -echo $internet_ip - -source .env -echo $MINIO_ENDPOINT -if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then - sed -i "s/127.0.0.1/${internet_ip}/" .env - -fi - -cd script ; -chmod +x *.sh ; -./init_pwd.sh -./env_check.sh; -cd .. ; -docker-compose up -d; -cd script ; -./docker_check_service.sh diff --git a/script/.env b/script/.env deleted file mode 100644 index e78a9ba0d..000000000 --- a/script/.env +++ /dev/null @@ -1,3 +0,0 @@ -USER=root -PASSWORD=openIMPassword -DATA_DIR=./ \ No newline at end of file diff --git a/script/batch_start_all.sh b/script/batch_start_all.sh index c2d78c509..085690717 100644 --- a/script/batch_start_all.sh +++ b/script/batch_start_all.sh @@ -9,7 +9,6 @@ need_to_start_server_shell=( push_start.sh msg_transfer_start.sh sdk_svr_start.sh - demo_svr_start.sh ) time=`date +"%Y-%m-%d %H:%M:%S"` echo "==========================================================">>../logs/openIM.log 2>&1 & diff --git a/script/build_push_k8s_images.sh b/script/build_push_k8s_images.sh new file mode 100644 index 000000000..432457298 --- /dev/null +++ b/script/build_push_k8s_images.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +version=errcode +repository=${1} +if [[ -z ${repository} ]] +then + echo "repository is empty" + exit 0 +fi + +set +e +echo "repository: ${repository}" +source ./path_info.cfg +echo "start to build docker images" +currentPwd=`pwd` +echo ${currentPwd} +i=0 +for path in ${service_source_root[*]} +do + cd ${path} + make build + image="${repository}/${image_names[${i}]}:$version" + echo ${image} + docker build -t $image . -f ./deploy.Dockerfile + echo "build ${image} success" + docker push ${image} + echo "push ${image} success" + echo "==============================" + i=$((i + 1)) + cd ${currentPwd} +done + +echo "build all images success" \ No newline at end of file diff --git a/script/check_all.sh b/script/check_all.sh index 076a71f6a..5b80c449e 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -6,9 +6,7 @@ source ./function.sh service_port_name=( openImWsPort openImApiPort - openImSdkWsPort - openImDemoPort - openImCmsApiPort + #openImSdkWsPort openImUserPort openImFriendPort openImMessagePort @@ -16,24 +14,14 @@ service_port_name=( openImGroupPort openImAuthPort openImPushPort - openImStatisticsPort - openImMessageCmsPort - openImAdminCmsPort - openImOfficePort - openImOrganizationPort openImConversationPort + openImThirdPort ) -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 - port=$(netstat -netulp | grep ./open_im | awk '{print $4}' | grep -w ${j} | awk -F '[:]' '{print $NF}') + port=$(ss -tunlp| grep open_im | 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} @@ -55,13 +43,13 @@ else fi -#check=$(ps aux | grep -w ./${timer_task_name} | grep -v grep | wc -l) -#if [ $check -ge 1 ]; then -# echo -e ${GREEN_PREFIX}"none port has been listening,belongs service is openImMsgTimer"${COLOR_SUFFIX} -#else -# echo -e ${RED_PREFIX}"openImMsgTimer service does not start normally"${COLOR_SUFFIX} -# echo -e ${RED_PREFIX}"please check ../logs/openIM.log "${COLOR_SUFFIX} -# exit -1 -#fi +check=$(ps aux | grep -w ./${cron_task_name} | grep -v grep | wc -l) +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} + exit -1 +fi echo -e ${YELLOW_PREFIX}"all services launch success"${COLOR_SUFFIX} diff --git a/script/demo_svr_start.sh b/script/demo_svr_start.sh deleted file mode 100644 index 85b36ab25..000000000 --- a/script/demo_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 -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 \ No newline at end of file diff --git a/script/docker_check_service.sh b/script/docker_check_service.sh index c1cca764a..87ed75802 100644 --- a/script/docker_check_service.sh +++ b/script/docker_check_service.sh @@ -3,10 +3,10 @@ echo "docker-compose ps..........................." docker-compose ps echo "check OpenIM, waiting 30s...................." -sleep 30 +sleep 60 echo "check OpenIM................................" ./check_all.sh -chmod +x ./enterprise/*.sh -./enterprise/check_all.sh +# chmod +x ./enterprise/*.sh +# ./enterprise/check_all.sh diff --git a/script/docker_start_all.sh b/script/docker_start_all.sh index 16283cf22..b7b24dd4b 100644 --- a/script/docker_start_all.sh +++ b/script/docker_start_all.sh @@ -9,7 +9,6 @@ need_to_start_server_shell=( push_start.sh msg_transfer_start.sh sdk_svr_start.sh - demo_svr_start.sh start_cron.sh ) diff --git a/script/enterprise/check_all.sh b/script/enterprise/check_all.sh index 844b978a5..0f6cb0d5c 100644 --- a/script/enterprise/check_all.sh +++ b/script/enterprise/check_all.sh @@ -10,7 +10,7 @@ service_port_name=( openImAdminPort openImChatPort ) -switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}') + for i in ${service_port_name[*]}; do list=$(cat $config_path | grep -w ${i} | awk -F '[:]' '{print $NF}') list_to_string $list diff --git a/script/enterprise/path_info.cfg b/script/enterprise/path_info.cfg index c3bf17d97..7106ac5d5 100644 --- a/script/enterprise/path_info.cfg +++ b/script/enterprise/path_info.cfg @@ -7,7 +7,7 @@ demo_server_binary_root="../bin/" #Global configuration file default dir -config_path="../docker-compose_cfg/config.yaml" +config_path="../.docker-compose_cfg/config.yaml" #servicefile dir path service_source_root=( diff --git a/script/init_pwd.sh b/script/init_pwd.sh new file mode 100644 index 000000000..6dd15c6c8 --- /dev/null +++ b/script/init_pwd.sh @@ -0,0 +1,11 @@ +echo "your user is:$USER" +echo "your password is:$PASSWORD" +echo "your minio endPoint is:$MINIO_ENDPOINT" +echo "your data dir is $DATA_DIR" + +sed -i "/^\([[:space:]]*dbMysqlUserName: *\).*/s//\1$USER/;0,/\([[:space:]]*dbUserName: *\).*/s//\1 $USER/;/\([[:space:]]*accessKeyID: *\).*/s//\1 $USER/;/\([[:space:]]*endpoint: *\).*/s//\1\"abc\"/;" ../config/config.yaml +sed -i "/^\([[:space:]]*dbMysqlPassword: *\).*/s//\1$PASSWORD/;/\([[:space:]]*dbPassword: *\).*/s//\1$PASSWORD/;/\([[:space:]]*secret: *\).*/s//\1$PASSWORD/;/\([[:space:]]*secretAccessKey: *\).*/s//\1$PASSWORD/;" ../config/config.yaml + +sed -i "/\([[:space:]]*endpoint: *\).*/s##\1$MINIO_ENDPOINT#;" ../config/config.yaml +sed -i "/\([[:space:]]*dbPassWord: *\).*/s//\1$PASSWORD/;" ../config/config.yaml +sed -i "/\([[:space:]]*secret: *\).*/s//\1$PASSWORD/;" ../.docker-compose_cfg/config.yaml diff --git a/script/mongo-init.sh b/script/mongo-init.sh new file mode 100644 index 000000000..3d1faa60b --- /dev/null +++ b/script/mongo-init.sh @@ -0,0 +1,12 @@ +mongo -- "$MONGO_INITDB_DATABASE" <>../logs/openIM.log 2>&1 & + echo "==========================start msg_gateway server===========================">>../logs/openIM.log + nohup ./${msg_gateway_name} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 & done #Check launched service process diff --git a/script/msg_transfer_start.sh b/script/msg_transfer_start.sh index 4d7fb96cd..86b1d62ee 100644 --- a/script/msg_transfer_start.sh +++ b/script/msg_transfer_start.sh @@ -2,7 +2,11 @@ #Include shell font styles and some basic information source ./style_info.cfg source ./path_info.cfg +source ./function.sh +list1=$(cat $config_path | grep messageTransferPrometheusPort | awk -F '[:]' '{print $NF}') +list_to_string $list1 +prome_ports=($ports_array) #Check if the service exists @@ -18,7 +22,13 @@ 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 & + prome_port=${prome_ports[$i]} + cmd="nohup ./${msg_transfer_name}" + 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 & done #Check launched service process diff --git a/script/mysql_database_init.sh b/script/mysql_database_init.sh deleted file mode 100644 index 2a5135e8e..000000000 --- a/script/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/script/path_info.cfg b/script/path_info.cfg index 3071a0a5d..75200e069 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -1,86 +1,92 @@ #Don't put the space between "=" msg_gateway_name="open_im_msg_gateway" msg_gateway_binary_root="../bin/" -msg_gateway_source_root="../cmd/open_im_msg_gateway/" +msg_gateway_source_root="../cmd/msggateway/" msg_name="open_im_msg" msg_binary_root="../bin/" -msg_source_root="../cmd/rpc/open_im_msg/" +msg_source_root="../cmd/rpc/msg/" push_name="open_im_push" push_binary_root="../bin/" -push_source_root="../cmd/open_im_push/" +push_source_root="../cmd/push/" msg_transfer_name="open_im_msg_transfer" msg_transfer_binary_root="../bin/" -msg_transfer_source_root="../cmd/open_im_msg_transfer/" -msg_transfer_service_num=2 +msg_transfer_source_root="../cmd/msgtransfer/" +msg_transfer_service_num=4 -timer_task_name="open_im_timer_task" -timer_task_binary_root="../bin/" -timer_task_source_root="../cmd/open_im_timer_task/" - 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/" + +cron_task_name="open_im_cron_task" +cron_task_binary_root="../bin/" +cron_task_source_root="../cmd/crontask/" +cmd_utils_name="open_im_cmd_utils" +cmd_utils_binary_root="../bin/" +cmd_utils_source_root="../cmd/cmduitls/" + #Global configuration file default dir config_path="../config/config.yaml" #servicefile dir path service_source_root=( #api service file - ../cmd/open_im_api/ - ../cmd/open_im_cms_api/ + ../cmd/api/ #rpc service file - ../cmd/rpc/open_im_user/ - ../cmd/rpc/open_im_friend/ - ../cmd/rpc/open_im_group/ - ../cmd/rpc/open_im_auth/ - ../cmd/rpc/open_im_admin_cms/ - ../cmd/rpc/open_im_message_cms/ - ../cmd/rpc/open_im_statistics/ - ../cmd/rpc/open_im_office/ - ../cmd/rpc/open_im_organization/ - ../cmd/rpc/open_im_conversation/ + ../cmd/rpc/user/ + ../cmd/rpc/friend/ + ../cmd/rpc/group/ + ../cmd/rpc/auth/ + ../cmd/rpc/conversation/ + ../cmd/rpc/third/ + ../cmd/crontask ${msg_gateway_source_root} - ${msg_transfer_source_root} + ${msg_transfer_source_root/} ${msg_source_root} ${push_source_root} - ${sdk_server_source_root} - ${demo_server_source_root} + # ${sdk_server_source_root} ) #service filename service_names=( #api service filename open_im_api - open_im_cms_api #rpc service filename open_im_user open_im_friend open_im_group open_im_auth - open_im_admin_cms - open_im_message_cms - open_im_statistics - open_im_office - open_im_organization open_im_conversation + open_im_third + open_im_cron_task ${msg_gateway_name} ${msg_transfer_name} ${msg_name} ${push_name} - ${sdk_server_name} - ${demo_server_name} + # ${sdk_server_name} ) - - +image_names=( + #api service file + api + #rpc service file + user + friend + group + auth + conversation + third + cron_task + msg_gateway + msg_transfer + msg + push + # sdk_server +) \ No newline at end of file diff --git a/script/push_start.sh b/script/push_start.sh index 8b2a47896..d047a0500 100644 --- a/script/push_start.sh +++ b/script/push_start.sh @@ -7,8 +7,11 @@ source ./function.sh list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') +list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}') list_to_string $list1 rpc_ports=($ports_array) +list_to_string $list2 +prome_ports=($ports_array) #Check if the service exists #If it is exists,kill this process @@ -22,7 +25,8 @@ 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 & + echo "==========================start push server===========================">>../logs/openIM.log + nohup ./${push_name} --port ${rpc_ports[$i]} --prometheus_port ${prome_ports[$i]} >>../logs/openIM.log 2>&1 & done sleep 3 diff --git a/script/sdk_svr_start.sh b/script/sdk_svr_start.sh index 738e0eba3..c1747fa3b 100644 --- a/script/sdk_svr_start.sh +++ b/script/sdk_svr_start.sh @@ -5,17 +5,12 @@ source ./path_info.cfg source ./function.sh ulimit -n 200000 -list1=$(cat $config_path | grep openImApiPort | awk -F '[:]' '{print $NF}') -list2=$(cat $config_path | grep openImWsPort | awk -F '[:]' '{print $NF}') +ws_address=$(cat $config_path | grep openImWsAddress | awk -F '[ ]' '{print $NF}') +api_address=$(cat $config_path | grep openImApiAddress | awk -F '[ ]' '{print $NF}') list3=$(cat $config_path | grep openImSdkWsPort | awk -F '[:]' '{print $NF}') logLevel=$(cat $config_path | grep remainLogLevel | 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) -list_to_string $list4 +sdkws_ports=($ports_array) @@ -29,7 +24,8 @@ 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]} -openIM_log_level ${logLevel} >>../logs/openIM.log 2>&1 & + echo "==========================start js sdk server===========================">>../logs/openIM.log + nohup ./${sdk_server_name} -openIM_ws_address ${ws_address} -sdk_ws_port ${sdkws_ports[0]} -openIM_api_address ${api_address} -openIM_log_level ${logLevel} >>../logs/openIM.log 2>&1 & #Check launched service process sleep 3 diff --git a/script/start_all.sh b/script/start_all.sh index c20c67ddb..01c6ab652 100644 --- a/script/start_all.sh +++ b/script/start_all.sh @@ -5,11 +5,10 @@ #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 - demo_svr_start.sh + msg_gateway_start.sh start_cron.sh ) time=`date +"%Y-%m-%d %H:%M:%S"` @@ -23,6 +22,7 @@ echo "==========================================================">>../logs/openI for i in ${need_to_start_server_shell[*]}; do chmod +x $i + echo "=====================exec ${i}======================">>../logs/openIM.log ./$i if [ $? -ne 0 ]; then exit -1 diff --git a/script/start_cron.sh b/script/start_cron.sh index 9c33478de..a0b62a2d2 100644 --- a/script/start_cron.sh +++ b/script/start_cron.sh @@ -18,7 +18,8 @@ sleep 1 cd ${cron_task_binary_root} #for ((i = 0; i < ${cron_task_service_num}; i++)); do - nohup ./${cron_task_name} >>../logs/openIM.log 2>&1 & + echo "==========================start cron_task process===========================">>../logs/openIM.log +nohup ./${cron_task_name} >>../logs/openIM.log 2>&1 & #done #Check launched service process diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index 6e60bcdcd..d3935e64f 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -8,38 +8,41 @@ source ./function.sh service_filename=( #api open_im_api - open_im_cms_api #rpc open_im_user open_im_friend open_im_group open_im_auth - open_im_admin_cms - open_im_message_cms - open_im_statistics ${msg_name} - open_im_office - open_im_organization open_im_conversation + open_im_third ) #service config port name service_port_name=( #api port name openImApiPort - openImCmsApiPort #rpc port name openImUserPort openImFriendPort openImGroupPort openImAuthPort - openImAdminCmsPort - openImMessageCmsPort - openImStatisticsPort openImMessagePort - openImOfficePort - openImOrganizationPort openImConversationPort + openImThirdPort +) + +service_prometheus_port_name=( + #api port name + openImApiPort + #rpc port name + userPrometheusPort + friendPrometheusPort + groupPrometheusPort + authPrometheusPort + messagePrometheusPort + conversationPrometheusPort + thirdPrometheusPort ) for ((i = 0; i < ${#service_filename[*]}; i++)); do @@ -59,13 +62,27 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do #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) + + portList2=$(cat $config_path | grep ${service_prometheus_port_name[$i]} | awk -F '[:]' '{print $NF}') + list_to_string $portList2 + prome_ports=($ports_array) #Start related rpc services based on the number of ports - for j in ${ports_array}; do + for ((j = 0; j < ${#service_ports[*]}; j++)); do #Start the service in the background - # ./${service_filename[$i]} -port $j & - nohup ./${service_filename[$i]} -port $j >>../logs/openIM.log 2>&1 & + if [ -z "${prome_ports[$j]}" ]; then + cmd="./${service_filename[$i]} --port ${service_ports[$j]}" + else + cmd="./${service_filename[$i]} --port ${service_ports[$j]} --prometheus_port ${prome_ports[$j]}" + fi + if [ $i -eq 0 -o $i -eq 1 ]; then + 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 & sleep 1 pid="netstat -ntlp|grep $j |awk '{printf \$7}'|cut -d/ -f1" - echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:$j pid:$(eval $pid)$COLOR_SUFFIX" + echo -e "${GREEN_PREFIX}${service_filename[$i]} start success,port number:${service_ports[$j]} pid:$(eval $pid)$COLOR_SUFFIX" done done diff --git a/script/timer_start.sh b/script/timer_start.sh deleted file mode 100644 index 7e2791f11..000000000 --- a/script/timer_start.sh +++ /dev/null @@ -1,35 +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 ./${timer_task_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -oldPid=`ps aux | grep -w ./${timer_task_name} | grep -v grep|awk '{print $2}'` - kill -9 $oldPid -fi -#Waiting port recycling -sleep 1 - -cd ${timer_task_binary_root} -nohup ./${timer_task_name} >>../logs/openIM.log 2>&1 & - - -#Check launched service process -check=`ps aux | grep -w ./${timer_task_name} | grep -v grep| wc -l` -if [ $check -ge 1 ] -then -newPid=`ps aux | grep -w ./${timer_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}${timer_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} -else - echo -e ${YELLOW_PREFIX}${timer_task_name}${COLOR_SUFFIX}${RED_PREFIX}"SERVICE START ERROR, PLEASE CHECK openIM.log"${COLOR_SUFFIX} -fi