From 68bc62d0c90edae0e3a226562ae72a190d838217 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Sun, 21 Jan 2024 10:25:39 +0800 Subject: [PATCH] feat: optimize mac deployment scripts --- scripts/docker-start-all.sh | 2 -- scripts/install/openim-msgtransfer.sh | 19 +++++++++++++------ scripts/install/openim-rpc.sh | 3 ++- scripts/start-all.sh | 2 ++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh index 2616b7bd1..162655553 100755 --- a/scripts/docker-start-all.sh +++ b/scripts/docker-start-all.sh @@ -28,8 +28,6 @@ openim::log::info "\n# Use Docker to start all openim service" trap 'openim::util::onCtrlC' INT -"${OPENIM_ROOT}"/scripts/init-config.sh --skip - "${OPENIM_ROOT}"/scripts/start-all.sh sleep 5 diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 18bbb3c02..f6039637c 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -12,6 +12,8 @@ # 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. +# Use: +# ./scripts/install/openim-msgtransfer.sh openim::msgtransfer::start # Common utilities, variables and checks for all build scripts. set -o errexit @@ -64,15 +66,20 @@ function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") NUM_PROCESSES=$(echo "$PIDS" | wc -l) - # NUM_PROCESSES=$(($NUM_PROCESSES - 1)) if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then - openim::log::info "Found $OPENIM_MSGGATEWAY_NUM processes named $OPENIM_OUTPUT_HOSTBIN" - for PID in $PIDS; do - ps -p $PID -o pid,cmd - done + openim::log::info "Found $OPENIM_MSGGATEWAY_NUM processes named $OPENIM_OUTPUT_HOSTBIN" + for PID in $PIDS; do + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + ps -p $PID -o pid,cmd + elif [[ "$OSTYPE" == "darwin"* ]]; then + ps -p $PID -o pid,comm + else + openim::log::error "Unsupported OS type: $OSTYPE" + fi + done else - openim::log::error_exit "Expected $OPENIM_MSGGATEWAY_NUM openim msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes." + openim::log::error_exit "Expected $OPENIM_MSGGATEWAY_NUM openim msgtransfer processes, but found $NUM_PROCESSES msgtransfer processes." fi } diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index b66004191..db1526d6a 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -123,12 +123,13 @@ function openim::rpc::start() { for ((i = 0; i < ${#OPENIM_RPC_SERVICE_LISTARIES[*]}; i++)); do # openim::util::stop_services_with_name ${OPENIM_RPC_SERVICE_LISTARIES openim::util::stop_services_on_ports ${OPENIM_RPC_PORT_LISTARIES[$i]} + openim::log::info "OpenIM ${OPENIM_RPC_SERVICE_LISTARIES[$i]} config path: ${OPENIM_RPC_CONFIG}" # Get the service and Prometheus ports. OPENIM_RPC_SERVICE_PORTS=( $(openim::util::list-to-string ${OPENIM_RPC_PORT_LISTARIES[$i]}) ) read -a OPENIM_RPC_SERVICE_PORTS_ARRAY <<< ${OPENIM_RPC_SERVICE_PORTS} - + OPENIM_RPC_PROM_PORTS=( $(openim::util::list-to-string ${OPENIM_RPC_PROM_PORT_LISTARIES[$i]}) ) read -a OPENIM_RPC_PROM_PORTS_ARRAY <<< ${OPENIM_RPC_PROM_PORTS} diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 64b931f50..b1f9b865b 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -32,6 +32,8 @@ if [[ $? -ne 0 ]]; then fi set -o errexit +"${OPENIM_ROOT}"/scripts/init-config.sh --skip + echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTARIES[@]}" openim::log::install_errexit