From 396f455c778e32c1d58c0bb192959b05d160da33 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com> Date: Fri, 7 Jul 2023 21:59:28 +0800 Subject: [PATCH] feat: fix scripts Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- scripts/build_all_service.sh | 2 +- scripts/enterprise/path_info.cfg | 2 +- scripts/githooks/pre-push | 15 +++++++++++++++ scripts/msg_gateway_start.sh | 14 +++++++++++--- scripts/path_info.cfg | 2 +- scripts/push_start.sh | 15 ++++++++++++--- scripts/start_all.sh | 14 +++++++++++--- scripts/start_cron.sh | 8 ++++++++ scripts/start_rpc_service.sh | 4 ++-- scripts/stop_all.sh | 14 +++++++++++--- 10 files changed, 73 insertions(+), 17 deletions(-) diff --git a/scripts/build_all_service.sh b/scripts/build_all_service.sh index 7359b39b3..7a583c970 100755 --- a/scripts/build_all_service.sh +++ b/scripts/build_all_service.sh @@ -25,7 +25,7 @@ echo -e "\n" echo -e "${BOLD_PREFIX}_____ _ _ _____ _____ _____ _____ _____ _____ _____ _____ _____ ${COLOR_SUFFIX}" -bin_dir="../bin" +bin_dir="$BIN_DIR" logs_dir="../logs" sdk_db_dir="../db/sdk/" # Automatically created when there is no bin, logs folder diff --git a/scripts/enterprise/path_info.cfg b/scripts/enterprise/path_info.cfg index 29d3112c1..168d46049 100644 --- a/scripts/enterprise/path_info.cfg +++ b/scripts/enterprise/path_info.cfg @@ -2,7 +2,7 @@ demo_server_name="openim_chat_api" -demo_server_binary_root="../bin/" +demo_server_binary_root="$BIN_DIR/" diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push index c8ad61a60..39c42832c 100644 --- a/scripts/githooks/pre-push +++ b/scripts/githooks/pre-push @@ -40,6 +40,21 @@ if [[ `git status --porcelain` ]]; then exit 1 fi +PURPLE_PREFIX="\033[35m" # Purple prefix +BOLD_PREFIX="\033[1m" # Bold prefix + +# Get current time +time=$(date +"%Y-%m-%d %H:%M:%S") + +# Print section separator +echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}" + +# Print time of submission +echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Time of submission: ${time}${COLOR_SUFFIX}" + +# Print section separator +echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}" + # #printMessage "Running the Flutter analyzer" #flutter analyze diff --git a/scripts/msg_gateway_start.sh b/scripts/msg_gateway_start.sh index 9f2016be7..9f4fb5e5f 100755 --- a/scripts/msg_gateway_start.sh +++ b/scripts/msg_gateway_start.sh @@ -14,9 +14,17 @@ # limitations under the License. #Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh +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 + +bin_dir="$OPENIM_ROOT/bin" +logs_dir="$OPENIM_ROOT/logs" +sdk_db_dir="$OPENIM_ROOT/sdk/db/" + ulimit -n 200000 list1=$(cat $config_path | grep openImMessageGatewayPort | awk -F '[:]' '{print $NF}') diff --git a/scripts/path_info.cfg b/scripts/path_info.cfg index 72759b2a4..a86add786 100755 --- a/scripts/path_info.cfg +++ b/scripts/path_info.cfg @@ -23,7 +23,7 @@ if [[ -z ${supported_architectures["$version-$architecture"]} ]]; then echo "================> Unsupported architecture: $architecture or version: $version" exit 1 fi - +Server Start Time echo "================> Architecture: $architecture" # Set the BIN_DIR based on the architecture and version diff --git a/scripts/push_start.sh b/scripts/push_start.sh index 80da0f575..f13056259 100755 --- a/scripts/push_start.sh +++ b/scripts/push_start.sh @@ -14,9 +14,18 @@ # limitations under the License. #Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg -source ./function.sh +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 + +bin_dir="$OPENIM_ROOT/bin" +logs_dir="$OPENIM_ROOT/logs" +sdk_db_dir="$OPENIM_ROOT/sdk/db/" + +cd "$OPENIM_ROOT/scripts/" list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}') diff --git a/scripts/start_all.sh b/scripts/start_all.sh index b847ef89b..92134ca44 100755 --- a/scripts/start_all.sh +++ b/scripts/start_all.sh @@ -17,11 +17,19 @@ #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. #Include shell font styles and some basic information -source ./style_info.cfg -source ./path_info.cfg - 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 + +bin_dir="$OPENIM_ROOT/bin" +logs_dir="$OPENIM_ROOT/logs" +sdk_db_dir="$OPENIM_ROOT/sdk/db/" + +cd "$OPENIM_ROOT/scripts/" + # Print title echo -e "${BOLD_PREFIX}${BLUE_PREFIX}OpenIM Server Start${COLOR_SUFFIX}" diff --git a/scripts/start_cron.sh b/scripts/start_cron.sh index efe06d8f7..26f9abf8b 100755 --- a/scripts/start_cron.sh +++ b/scripts/start_cron.sh @@ -13,11 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +#Include shell font styles and some basic information 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 + +bin_dir="$OPENIM_ROOT/bin" +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 diff --git a/scripts/start_rpc_service.sh b/scripts/start_rpc_service.sh index 940bf57c6..e67711d49 100755 --- a/scripts/start_rpc_service.sh +++ b/scripts/start_rpc_service.sh @@ -20,7 +20,7 @@ source $OPENIM_ROOT/scripts/style_info.cfg source $OPENIM_ROOT/scripts/path_info.cfg source $OPENIM_ROOT/scripts/function -bin_dir="$OPENIM_ROOT/bin" +bin_dir="$BIN_DIR" logs_dir="$OPENIM_ROOT/logs" sdk_db_dir="$OPENIM_ROOT/sdk/db/" @@ -80,7 +80,7 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do kill -9 $(eval $pid) sleep 0.5 fi - cd ../bin + cd $ #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} diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh index f04779d43..fac3d7f41 100755 --- a/scripts/stop_all.sh +++ b/scripts/stop_all.sh @@ -13,11 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -#fixme This scripts is to stop the service +#Include shell font styles and some basic information +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -source ./style_info.cfg -source ./path_info.cfg +#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 +bin_dir="$OPENIM_ROOT/bin" +logs_dir="$OPENIM_ROOT/logs" +sdk_db_dir="$OPENIM_ROOT/sdk/db/" + +cd "$OPENIM_ROOT/scripts/" for i in ${service_names[*]}; do #Check whether the service exists