diff --git a/scripts/README.md b/scripts/README.md index e0cd5bd56..986de0141 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -76,7 +76,7 @@ scripts/ ├── msg_gateway_start.sh # Script to start message gateway service ├── msg_transfer_start.sh # Script to start message transfer service ├── path_info.sh # Script containing path information -├── push_start.sh # Script to start push service +├── openim-push.sh # Script to start push service ├── release.sh # Script to perform release process ├── start_all.sh # Script to start all services ├── openim-crontask.sh # Script to start cron jobs @@ -264,6 +264,10 @@ openim::util::stop_services_with_name nginx apache ## examples Scripts to perform various build, install, analysis, etc operations. +The script directory design of OpenIM and the writing of scripts and tools refer to many excellent open source projects, such as helm, iam, kubernetes, docker, etc. + +Maybe they'll give you inspiration for later maintenance... + These scripts keep the root level Makefile small and simple. Examples: diff --git a/scripts/batch_start_all.sh b/scripts/batch_start_all.sh index c84eb8cdf..91f5a4da0 100755 --- a/scripts/batch_start_all.sh +++ b/scripts/batch_start_all.sh @@ -28,7 +28,7 @@ trap 'openim::util::onCtrlC' INT need_to_start_server_shell=( "start_rpc_service.sh" "msg_gateway_start.sh" - "push_start.sh" + "openim-push.sh" "msg_transfer_start.sh" ) diff --git a/scripts/docker_start_all.sh b/scripts/docker_start_all.sh index 057f0504d..d05c840a7 100755 --- a/scripts/docker_start_all.sh +++ b/scripts/docker_start_all.sh @@ -27,7 +27,7 @@ trap 'openim::util::onCtrlC' INT need_to_start_server_shell=( ${SCRIPTS_ROOT}/start_rpc_service.sh ${SCRIPTS_ROOT}/msg_gateway_start.sh - ${SCRIPTS_ROOT}/push_start.sh + ${SCRIPTS_ROOT}/openim-push.sh ${SCRIPTS_ROOT}/msg_transfer_start.sh ${SCRIPTS_ROOT}/openim-crontask.sh ) diff --git a/scripts/install/install.sh b/scripts/install/install.sh index c7277a797..a2a0f2840 100755 --- a/scripts/install/install.sh +++ b/scripts/install/install.sh @@ -17,5 +17,5 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source ${OPENIM_ROOT}/scripts/install/common.sh -# common.sh environment.sh mariadb_for_ubuntu.sh msg_transfer_start.sh push_start.sh start_rpc_service.sh vimrc -# dependency.sh install.sh msg_gateway_start.sh openim-crontask.sh redis_for_ubuntu.sh test.sh \ No newline at end of file +# common.sh environment.sh mariadb_for_ubuntu.sh msg_transfer_start.sh openim-push.sh start_rpc_service.sh +# dependency.sh install.sh msg_gateway_start.sh openim-crontask.sh redis_for_ubuntu.sh test.sh man.sh \ No newline at end of file diff --git a/scripts/install/man.sh b/scripts/install/man.sh old mode 100644 new mode 100755 diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh index b1a6f3327..88f3fc77b 100755 --- a/scripts/install/openim-crontask.sh +++ b/scripts/install/openim-crontask.sh @@ -29,11 +29,11 @@ # Usage: # 1. Direct Script Execution: # This will start the OpenIM CronTask directly through a background process. -# Example: ./[script-name].sh +# Example: ./openim-crontask.sh # # 2. Controlling through Functions for systemctl operations: # Specific operations like installation, uninstallation, and status check can be executed by passing the respective function name as an argument to the script. -# Example: ./[script-name].sh openim::crontask::install +# Example: ./openim-crontask.sh openim::crontask::install # # Note: Ensure that the appropriate permissions and environmental variables are set prior to script execution. # diff --git a/scripts/install/push_start.sh b/scripts/install/openim-push.sh similarity index 76% rename from scripts/install/push_start.sh rename to scripts/install/openim-push.sh index a4beb4145..2b6e10844 100755 --- a/scripts/install/push_start.sh +++ b/scripts/install/openim-push.sh @@ -12,7 +12,30 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +# +# OpenIM Push Control Script +# +# Description: +# This script provides a control interface for the OpenIM Push service within a Linux environment. It supports two installation methods: installation via function calls to systemctl, and direct installation through background processes. +# +# Features: +# 1. Robust error handling leveraging Bash built-ins such as 'errexit', 'nounset', and 'pipefail'. +# 2. Capability to source common utility functions and configurations, ensuring environmental consistency. +# 3. Comprehensive logging tools, offering clear operational insights. +# 4. Support for creating, managing, and interacting with Linux systemd services. +# 5. Mechanisms to verify the successful running of the service. +# +# Usage: +# 1. Direct Script Execution: +# This will start the OpenIM push directly through a background process. +# Example: ./openim-push.sh +# +# 2. Controlling through Functions for systemctl operations: +# Specific operations like installation, uninstallation, and status check can be executed by passing the respective function name as an argument to the script. +# Example: ./openim-push.sh openim::push::install +# +# Note: Ensure that the appropriate permissions and environmental variables are set prior to script execution. +# set -o errexit set +o nounset set -o pipefail @@ -22,14 +45,14 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) SERVER_NAME="openim-push" -# openim::log::status "Start OpenIM Push, binary root: ${SERVER_NAME}" -# openim::log::info "Start OpenIM Push, path: ${OPENIM_PUSH_BINARY}" +openim::log::status "Start OpenIM Push, binary root: ${SERVER_NAME}" +openim::log::info "Start OpenIM Push, path: ${OPENIM_PUSH_BINARY}" -# openim::util::stop_services_with_name ${SERVER_NAME} +openim::util::stop_services_with_name ${SERVER_NAME} -# openim::log::status "start push process, path: ${OPENIM_PUSH_BINARY}" -# nohup ${OPENIM_PUSH_BINARY} >>${LOG_FILE} 2>&1 & -# openim::util::check_process_names ${SERVER_NAME} +openim::log::status "start push process, path: ${OPENIM_PUSH_BINARY}" +nohup ${OPENIM_PUSH_BINARY} >>${LOG_FILE} 2>&1 & +openim::util::check_process_names ${SERVER_NAME} ###################################### Linux Systemd ###################################### SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" @@ -109,13 +132,6 @@ fi -cd $SCRIPTS_ROOT - -bin_dir="$BIN_DIR" -logs_dir="$OPENIM_ROOT/logs" - -cd "$OPENIM_ROOT/scripts/" - list1=$(cat $config_path | grep openImPushPort | awk -F '[:]' '{print $NF}') list2=$(cat $config_path | grep pushPrometheusPort | awk -F '[:]' '{print $NF}') openim::util::list-to-string $list1 diff --git a/scripts/install_im_compose.sh b/scripts/install_im_compose.sh index 732b0f27c..9577e1f9f 100755 --- a/scripts/install_im_compose.sh +++ b/scripts/install_im_compose.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Copyright © 2023 OpenIM. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/lib/golang.sh b/scripts/lib/golang.sh index 05c926f39..c96f71116 100755 --- a/scripts/lib/golang.sh +++ b/scripts/lib/golang.sh @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + # The golang package that we are building. OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" readonly KUBE_GO_PACKAGE=github.com/openimsdk/open-im-server @@ -95,7 +96,7 @@ START_SCRIPTS_PATH="${OPENIM_ROOT}/scripts/install/" openim::golang::start_script_list() { local targets=( start-rpc_service.sh - push_start.sh + openim-push.sh msg_transfer_start.sh msg_gateway_start.sh openim-crontask.sh