feat: add start sctips help

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-08-14 21:46:12 +08:00
parent 0dcdcbed4b
commit f4c464003c
14 changed files with 479 additions and 346 deletions
+26 -13
View File
@@ -20,26 +20,39 @@ set -o nounset
set -o pipefail
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
source "${OPENIM_ROOT}/scripts/install/common.sh"
set +o errexit
openim::golang::check_openim_binaries
if [[ $? -ne 0 ]]; then
openim::log::error "OpenIM binaries are not found. Please run 'make' to build binaries."
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
${OPENIM_ROOT}/scripts/build_all_service.sh
fi
set -o errexit
scripts_to_run=$(openim::golang::start_script_list)
echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTARIES[@]}"
openim::log::install_errexit
for script in $scripts_to_run; do
openim::log::info "Executing: $script"
"$script"
if [ $? -ne 0 ]; then
# Print error message and exit
openim::log::error "Error executing ${i}. Exiting..."
exit -1
fi
done
# Function to execute the scripts.
function execute_scripts() {
for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do
# Check if the script file exists and is executable.
if [[ -x "$script_path" ]]; then
openim::log::status "Starting script: ${script_path##*/}" # Log the script name.
# Execute the script.
"$script_path"
openim::log::success "OpenIM Server has been started successfully!"
# Check if the script executed successfully.
if [[ $? -eq 0 ]]; then
openim::log::info "${script_path##*/} executed successfully."
else
openim::log::errexit "Error executing ${script_path##*/}."
fi
else
openim::log::errexit "Script ${script_path##*/} is missing or not executable."
fi
done
}
execute_scripts