mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 14:29:19 +08:00
fix: fix docker compose scripts (#1546)
* fix: fix docker compose scripts Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix scripts and rea Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
+49
-11
@@ -24,12 +24,10 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
|
||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
# (en: Define a profile array that contains the name path of the profile to be generated.)
|
||||
readonly ENV_FILE=${ENV_FILE:-"${OPENIM_ROOT}/scripts/install/environment.sh"}
|
||||
|
||||
# (en: Defines an associative array where the keys are the template files and the values are the corresponding output files.)
|
||||
declare -A TEMPLATES=(
|
||||
["${OPENIM_ROOT}/deployments/templates/env_template.yaml"]="${OPENIM_ROOT}/.env"
|
||||
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/.env"
|
||||
["${OPENIM_ROOT}/deployments/templates/openim.yaml"]="${OPENIM_ROOT}/config/config.yaml"
|
||||
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/prometheus.yml"
|
||||
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml"
|
||||
@@ -37,6 +35,42 @@ declare -A TEMPLATES=(
|
||||
|
||||
openim::log::info "Read more configuration information: https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md"
|
||||
|
||||
# New variables for argument handling
|
||||
FORCE_OVERWRITE=false
|
||||
SKIP_EXISTING=false
|
||||
|
||||
# Function to display help
|
||||
show_help() {
|
||||
echo "Usage: $(basename "$0") [options]"
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " --force Overwrite existing files without prompt"
|
||||
echo " --skip Skip generation if file exists"
|
||||
}
|
||||
|
||||
# Parse command-line options
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--force)
|
||||
FORCE_OVERWRITE=true
|
||||
shift
|
||||
;;
|
||||
--skip)
|
||||
SKIP_EXISTING=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for template in "${!TEMPLATES[@]}"; do
|
||||
if [[ ! -f "${template}" ]]; then
|
||||
openim::log::error_exit "Template file ${template} does not exist..."
|
||||
@@ -48,14 +82,19 @@ for template in "${!TEMPLATES[@]}"; do
|
||||
IFS=';' read -ra OUTPUT_FILES <<< "${TEMPLATES[$template]}"
|
||||
for output_file in "${OUTPUT_FILES[@]}"; do
|
||||
if [[ -f "${output_file}" ]]; then
|
||||
echo -n "File ${output_file} already exists. Overwrite? (Y/N): "
|
||||
read -r -n 1 REPLY
|
||||
echo # Adds a line to wrap after user input
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
openim::log::info "Overwriting ${output_file}. Previous configuration will be lost."
|
||||
else
|
||||
openim::log::info "Skipping generation of ${output_file}."
|
||||
if [[ "${FORCE_OVERWRITE}" == true ]]; then
|
||||
openim::log::info "Force overwriting ${output_file}."
|
||||
elif [[ "${SKIP_EXISTING}" == true ]]; then
|
||||
openim::log::info "Skipping generation of ${output_file} as it already exists."
|
||||
continue
|
||||
else
|
||||
echo -n "File ${output_file} already exists. Overwrite? (Y/N): "
|
||||
read -r -n 1 REPLY
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
openim::log::info "Skipping generation of ${output_file}."
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -72,5 +111,4 @@ for template in "${!TEMPLATES[@]}"; do
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
openim::log::success "✨ All configuration files have been successfully generated!"
|
||||
|
||||
@@ -66,7 +66,7 @@ function openim::api::start() {
|
||||
for ((j = 0; j < ${#OPENIM_API_SERVICE_PORTS[@]}; j++)); do
|
||||
openim::log::info "Starting ${OPENIM_API_SERVICE_LISTARIES[$i]} service, port: ${OPENIM_API_SERVICE_PORTS[j]}, binary root: ${OPENIM_OUTPUT_HOSTBIN}/${OPENIM_API_SERVICE_LISTARIES[$i]}"
|
||||
openim::api::start_service "${OPENIM_API_SERVICE_LISTARIES[$i]}" "${OPENIM_API_PORT_LISTARIES[j]}"
|
||||
sleep 1
|
||||
sleep 2
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ function openim::rpc::start() {
|
||||
done
|
||||
done
|
||||
|
||||
sleep 0.5
|
||||
sleep 1
|
||||
|
||||
openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]}
|
||||
# openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
OPENIM_VERBOSE="${OPENIM_VERBOSE:-5}"
|
||||
|
||||
# Enable logging by default. Set to false to disable.
|
||||
ENABLE_LOGGING=true
|
||||
ENABLE_LOGGING="${ENABLE_LOGGING:-true}"
|
||||
|
||||
# If OPENIM_OUTPUT is not set, set it to the default value
|
||||
if [[ ! -v OPENIM_OUTPUT ]]; then
|
||||
|
||||
Reference in New Issue
Block a user