Files
open-im-server/scripts/start_all.sh
T

85 lines
2.8 KiB
Bash
Raw Normal View History

2023-06-30 23:22:58 +08:00
#!/usr/bin/env bash
2023-07-04 11:15:20 +08:00
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
2023-07-04 20:18:39 +08:00
#FIXME This script is the startup script for multiple servers.
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
2023-06-30 23:22:58 +08:00
2023-07-07 18:20:08 +08:00
#Include shell font styles and some basic information
2023-07-09 15:28:19 +08:00
SCRIPTS_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
OPENIM_ROOT=$(dirname "${SCRIPTS_ROOT}")/..
2023-07-07 21:27:07 +08:00
2023-07-07 21:59:28 +08:00
#Include shell font styles and some basic information
2023-07-09 16:51:43 +08:00
source $SCRIPTS_ROOT/style_info.sh
source $SCRIPTS_ROOT/path_info.sh
2023-07-09 15:28:19 +08:00
source $SCRIPTS_ROOT/function.sh
2023-07-07 21:59:28 +08:00
2023-07-09 15:28:19 +08:00
cd $SCRIPTS_ROOT
2023-07-09 16:51:43 +08:00
echo -e "${BACKGROUND_GREEN}=======>SCRIPTS_ROOT=$SCRIPTS_ROOT${COLOR_SUFFIX}"
echo -e "${BACKGROUND_GREEN}=======>OPENIM_ROOT=$OPENIM_ROOT${COLOR_SUFFIX}"
echo -e "${BACKGROUND_GREEN}=======>pwd=$PWD${COLOR_SUFFIX}"
2023-07-09 15:28:19 +08:00
bin_dir="$BIN_DIR"
2023-07-07 21:59:28 +08:00
logs_dir="$OPENIM_ROOT/logs"
sdk_db_dir="$OPENIM_ROOT/sdk/db/"
2023-07-07 18:20:08 +08:00
# Print title
2023-07-09 15:28:19 +08:00
echo -e "${BOLD_PREFIX}${BLUE_PREFIX}================> OpenIM Server Start${COLOR_SUFFIX}"
2023-07-07 18:20:08 +08:00
# Get current time
time=$(date +"%Y-%m-%d %H:%M:%S")
# Print section separator
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
# Print server start time
echo -e "${BOLD_PREFIX}${CYAN_PREFIX}Server Start Time: ${time}${COLOR_SUFFIX}"
# Print section separator
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
# FIXME Put the shell script names here
2023-06-30 23:22:58 +08:00
need_to_start_server_shell=(
start_rpc_service.sh
push_start.sh
msg_transfer_start.sh
msg_gateway_start.sh
start_cron.sh
)
2023-07-04 20:18:39 +08:00
2023-07-07 18:20:08 +08:00
# Loop through the script names and execute them
2023-06-30 23:22:58 +08:00
for i in ${need_to_start_server_shell[*]}; do
chmod +x $i
2023-07-07 18:20:08 +08:00
echo -e ""
# Print script execution message
2023-07-09 16:51:43 +08:00
echo -e "=========> ${BACKGROUND_GREEN}Executing ${i}...${COLOR_SUFFIX}"
2023-07-07 18:20:08 +08:00
echo -e ""
2023-06-30 23:22:58 +08:00
./$i
2023-07-07 18:20:08 +08:00
# Check if the script executed successfully
2023-07-04 20:18:39 +08:00
if [ $? -ne 0 ]; then
2023-07-07 18:20:08 +08:00
# Print error message and exit
echo "${BOLD_PREFIX}${RED_PREFIX}Error executing ${i}. Exiting...${COLOR_SUFFIX}"
2023-07-04 20:18:39 +08:00
exit -1
2023-06-30 23:22:58 +08:00
fi
done
2023-07-07 18:20:08 +08:00
# Print section separator
2023-07-07 21:27:07 +08:00
echo -e "${PURPLE_PREFIX}==========================================================${COLOR_SUFFIX}"
2023-07-07 18:20:08 +08:00
# Print completion message
2023-07-07 21:27:07 +08:00
echo -e "${GREEN_PREFIX}${BOLD_PREFIX}OpenIM Server has been started successfully!${COLOR_SUFFIX}"