forked from freeleaps/freeleaps-pub
Merged PR 65: Update for components adding comments [:COMPONENT_SETTINGS]
Update for components adding comments [:COMPONENT_SETTINGS]
This commit is contained in:
commit
ae59047e1c
@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Modifying it manually is not recommended
|
||||
|
||||
# All components that can be started in the DevBox container. [:COMPONENT_SETTINGS]
|
||||
DEVBOX_COMPONENTS=("devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
|
||||
log_info() {
|
||||
echo "[INFO] $(date '+%Y-%m-%d %H:%M:%S') $*"
|
||||
}
|
||||
@ -612,28 +615,12 @@ build_local_image() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Define the local components and their corresponding ports
|
||||
local_components_ports_keys=("devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
|
||||
local_components_ports_values=("8007" "8003" "8013" "8005" "8012" "8004")
|
||||
|
||||
|
||||
# used for repository username and password encoding
|
||||
url_encode() {
|
||||
echo "$1" | sed 's/@/%40/g'
|
||||
}
|
||||
|
||||
# Get the port number for a local component
|
||||
get_port() {
|
||||
local comp="$1"
|
||||
local port=""
|
||||
for i in "${!local_components_ports_keys[@]}"; do
|
||||
if [ "${local_components_ports_keys[i]}" = "$comp" ]; then
|
||||
port="${local_components_ports_values[i]}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
###############################################
|
||||
@ -641,6 +628,7 @@ get_port() {
|
||||
###############################################
|
||||
init_compile_env() {
|
||||
|
||||
# Update for export environments []
|
||||
docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Starting DevBox initialization..."
|
||||
|
||||
@ -653,7 +641,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
export DEVBOX_FRONTEND_PORT="${DEVBOX_FRONTEND_PORT}"
|
||||
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') USE_LOCAL_COMPONENT_VAL: ${USE_LOCAL_COMPONENT_VAL}"
|
||||
# Check if the working home directory exists, if not, create it
|
||||
# Check if the working home directory exists, if not, create it. [:COMPONENT_SETTINGS]
|
||||
if [[ "$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
||||
# Local component environment variables
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Use local component dev environment."
|
||||
@ -685,12 +673,11 @@ if [[ "$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
||||
export VITE_PROXY_API_CHAT_URL=http://localhost:8012
|
||||
EOFinner
|
||||
|
||||
# Update set VITE_PROXY_WEBSOCKET_CHAT_URL and VITE_PROXY_API_CHAT_URL in frontend/.env.development
|
||||
# Update set VITE_PROXY_WEBSOCKET_CHAT_URL and VITE_PROXY_API_CHAT_URL in frontend/.env.development
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Update VITE_PROXY_WEBSOCKET_CHAT_URL and VITE_PROXY_API_CHAT_URL in frontend/.env.development"
|
||||
sed -i "s|VITE_PROXY_WEBSOCKET_CHAT_URL=.*|VITE_PROXY_WEBSOCKET_CHAT_URL=ws://chat:8012|g" /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
sed -i "s|VITE_PROXY_API_CHAT_URL=.*|VITE_PROXY_API_CHAT_URL=http://chat:8012|g" /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
|
||||
|
||||
else
|
||||
# Online component environment variables
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Use online component dev environment."
|
||||
@ -720,10 +707,12 @@ else
|
||||
export VITE_PROXY_WEBSOCKET_CHAT_URL=wss://freeleaps-alpha.com
|
||||
export VITE_PROXY_API_CHAT_URL=https://freeleaps-alpha.com
|
||||
EOFinner
|
||||
|
||||
# Update set VITE_PROXY_WEBSOCKET_CHAT_URL and VITE_PROXY_API_CHAT_URL in frontend/.env.development
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Update VITE_PROXY_WEBSOCKET_CHAT_URL and VITE_PROXY_API_CHAT_URL in frontend/.env.development"
|
||||
sed -i "s|VITE_PROXY_WEBSOCKET_CHAT_URL=.*|VITE_PROXY_WEBSOCKET_CHAT_URL=wss://freeleaps-alpha.com|g" /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
sed -i "s|VITE_PROXY_API_CHAT_URL=.*|VITE_PROXY_API_CHAT_URL=https://freeleaps-alpha.com|g" /home/devbox/freeleaps/frontend/freeleaps/.env.development
|
||||
|
||||
|
||||
echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Online component dev environment variables set."
|
||||
fi
|
||||
@ -1198,6 +1187,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
# Set the threshold for the time difference
|
||||
threshold=150
|
||||
|
||||
# Frontend environment variable settings. [:COMPONENT_SETTINGS]
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') USE_LOCAL_COMPONENT_VAL: \$USE_LOCAL_COMPONENT_VAL"
|
||||
if [[ "\$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use local component dev environment."
|
||||
@ -1355,6 +1345,7 @@ docker exec -i "$DEVBOX_NAME" bash <<EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Frontend environment variable settings. [:COMPONENT_SETTINGS]
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') USE_LOCAL_COMPONENT_VAL: \$USE_LOCAL_COMPONENT_VAL"
|
||||
if [[ "\$USE_LOCAL_COMPONENT_VAL" == "true" ]]; then
|
||||
echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Use local component dev environment."
|
||||
@ -1482,7 +1473,8 @@ devbox_init_command() {
|
||||
local FORCE_INIT="$(get_arg '--force')"
|
||||
|
||||
local is_pull_all_components=true
|
||||
local components=("devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
# set local components to content of DEVBOX_COMPONENTS
|
||||
local components=("${DEVBOX_COMPONENTS[@]}")
|
||||
local start_components=()
|
||||
|
||||
# Check if using local components
|
||||
@ -1657,7 +1649,10 @@ devbox_init_command() {
|
||||
# Check if any component is running on the host when force init is not set
|
||||
if [ -z "$FORCE_INIT" ]; then
|
||||
running_containers=$(docker ps --format '{{.Names}}')
|
||||
components_to_check=("devbox" "freeleaps2-gitea" "freeleaps2-mongodb" "freeleaps2-rabbitmq" "freeleaps2-redis" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
# Check if any component is running on the host
|
||||
components_to_check=("devbox" "freeleaps2-gitea" "freeleaps2-mongodb" "freeleaps2-rabbitmq" "freeleaps2-redis")
|
||||
components_to_check+=("${DEVBOX_COMPONENTS[@]}")
|
||||
|
||||
for comp in "${components_to_check[@]}"; do
|
||||
if echo "$running_containers" | grep -qx "$comp"; then
|
||||
echo
|
||||
@ -2335,7 +2330,7 @@ devbox_deinit_command() {
|
||||
fi
|
||||
|
||||
# Stop and remove other components
|
||||
local components=("devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
local components=("${DEVBOX_COMPONENTS[@]}")
|
||||
for component in "${components[@]}"; do
|
||||
if [[ -f "$WORKING_HOME/.${component}-instance" ]]; then
|
||||
local component_container_id
|
||||
@ -2486,16 +2481,26 @@ devbox_start_command() {
|
||||
if [[ "$USE_LOCAL_COMPONENT" == "true" ]]; then
|
||||
# If no component is specified, start all components
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=( "gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
COMPONENTS+=("${DEVBOX_COMPONENTS[@]}")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
else
|
||||
# If no component is specified, start all components
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "devbox")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
else
|
||||
if [[ "$COMPONENT" == "devsvc" || "$COMPONENT" == "notification" || "$COMPONENT" == "content" || "$COMPONENT" == "central_storage" || "$COMPONENT" == "chat" || "$COMPONENT" == "authentication" ]]; then
|
||||
# Check if the component is a local component from DEVBOX_COMPONENT
|
||||
found=false
|
||||
for item in "${DEVBOX_COMPONENTS[@]}"; do
|
||||
if [ "$item" = "$COMPONENT" ]; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" = true ]; then
|
||||
exit_with_message "Remote component $COMPONENT cannot be restarted, please use local components." 1
|
||||
fi
|
||||
|
||||
@ -2503,37 +2508,54 @@ devbox_start_command() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start the specified components
|
||||
BASIC_COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
for comp in "${COMPONENTS[@]}"; do
|
||||
case "$comp" in
|
||||
"gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||
log_info "Starting $comp service..."
|
||||
# Check if the component container file exists
|
||||
local component_container_id_file_path="${WORKING_HOME}/.${comp}-instance"
|
||||
if [[ ! -f "$component_container_id_file_path" ]]; then
|
||||
log_error "$comp container is not running. Please run 'devbox init' first."
|
||||
else
|
||||
local component_container_id=$(cat "$component_container_id_file_path")
|
||||
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${component_container_id}\$"; then
|
||||
log_info "$comp container is not running, starting container..."
|
||||
# Start the container
|
||||
if ! docker start "${component_container_id}"; then
|
||||
log_error "Failed to start $comp container."
|
||||
else
|
||||
log_info "$comp container started successfully."
|
||||
fi
|
||||
else
|
||||
log_info "$comp container is already running."
|
||||
fi
|
||||
should_start=false
|
||||
|
||||
# Check if it's in BASIC_COMPONENTS
|
||||
for basic in "${BASIC_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$basic" ]; then
|
||||
should_start=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if it's in DEVBOX_COMPONENTS
|
||||
if [ "$should_start" = false ]; then
|
||||
for dev in "${DEVBOX_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$dev" ]; then
|
||||
should_start=true
|
||||
break
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$should_start" = true ]; then
|
||||
log_info "Starting $comp service..."
|
||||
local component_container_id_file_path="${WORKING_HOME}/.${comp}-instance"
|
||||
|
||||
if [ ! -f "$component_container_id_file_path" ]; then
|
||||
log_error "$comp container is not running. Please run 'devbox init' first."
|
||||
else
|
||||
local component_container_id=$(cat "$component_container_id_file_path")
|
||||
if ! docker ps --no-trunc --format '{{.ID}}' | grep -q "^${component_container_id}\$"; then
|
||||
log_info "$comp container is not running, starting container..."
|
||||
if ! docker start "${component_container_id}"; then
|
||||
log_error "Failed to start $comp container."
|
||||
else
|
||||
log_info "$comp container started successfully."
|
||||
fi
|
||||
else
|
||||
log_info "$comp container is already running."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
# Check if $FREELEAPS_ENDPOINT is not empty and start the frontend and backend services
|
||||
if [[ "$FREELEAPS_ENDPOINT" != "" ]]; then
|
||||
# Sleep for 10 seconds to allow the services to start and echo 10 seconds increase from 1 to 10 in each second
|
||||
@ -2653,51 +2675,70 @@ devbox_stop_command() {
|
||||
|
||||
# If the DevBox container is not running, exit
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
COMPONENTS+=("${DEVBOX_COMPONENTS[@]}")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
|
||||
# Stop the specified components
|
||||
BASIC_COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis")
|
||||
|
||||
for comp in "${COMPONENTS[@]}"; do
|
||||
case "$comp" in
|
||||
"devbox")
|
||||
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "Stopping devbox..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
# Remove the frontend and backend pid files
|
||||
rm -f "${WORKING_HOME}/.backend.pid"
|
||||
rm -f "${WORKING_HOME}/.frontend.pid"
|
||||
else
|
||||
log_info "DevBox container is not running."
|
||||
fi
|
||||
if [ "$comp" = "devbox" ]; then
|
||||
if [ -f "${WORKING_HOME}/.devbox-instance" ]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "Stopping devbox..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
rm -f "${WORKING_HOME}/.backend.pid"
|
||||
rm -f "${WORKING_HOME}/.frontend.pid"
|
||||
else
|
||||
log_info "Backend service is not running."
|
||||
log_info "DevBox container is not running."
|
||||
fi
|
||||
;;
|
||||
|
||||
"gitea"| "mongodb"| "rabbitmq" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "Stopping $comp service..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
else
|
||||
log_info "Backend service is not running."
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
should_stop=false
|
||||
|
||||
for basic in "${BASIC_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$basic" ]; then
|
||||
should_stop=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$should_stop" = false ]; then
|
||||
for dev in "${DEVBOX_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$dev" ]; then
|
||||
should_stop=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$should_stop" = true ]; then
|
||||
if [ -f "${WORKING_HOME}/.${comp}-instance" ]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "Stopping $comp service..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
else
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
exit_with_message "Stopped Freeleaps services successfully. " 0
|
||||
|
||||
@ -2724,79 +2765,46 @@ devbox_status_command() {
|
||||
|
||||
# If no component is specified, check all components
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
COMPONENTS+=("${DEVBOX_COMPONENTS[@]}")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
|
||||
# Check the status of the specified components
|
||||
BASIC_COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis")
|
||||
ALL_COMPONENTS=("${BASIC_COMPONENTS[@]}" "${DEVBOX_COMPONENTS[@]}" "devbox")
|
||||
|
||||
for comp in "${COMPONENTS[@]}"; do
|
||||
case "$comp" in
|
||||
"mongodb")
|
||||
log_info "Checking MongoDB status..."
|
||||
if [[ -f "${WORKING_HOME}/.mongodb-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.mongodb-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "[RESULT]: MongoDB container is running."
|
||||
else
|
||||
log_info "[RESULT]: MongoDB container is not running."
|
||||
fi
|
||||
else
|
||||
log_info "[RESULT]: MongoDB container is not running."
|
||||
fi
|
||||
;;
|
||||
|
||||
"rabbitmq")
|
||||
log_info "Checking RabbitMQ status..."
|
||||
if [[ -f "${WORKING_HOME}/.rabbitmq-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.rabbitmq-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "[RESULT]: RabbitMQ container is running."
|
||||
else
|
||||
log_info "[RESULT]: RabbitMQ container is not running."
|
||||
fi
|
||||
else
|
||||
log_info "[RESULT]: RabbitMQ container is not running."
|
||||
fi
|
||||
;;
|
||||
|
||||
"devbox")
|
||||
log_info "Checking devbox service status..."
|
||||
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "[RESULT]: devbox container is running."
|
||||
else
|
||||
log_info "[RESULT]: devbox container is not running."
|
||||
fi
|
||||
else
|
||||
log_info "[RESULT]: devbox container is not running."
|
||||
fi
|
||||
;;
|
||||
|
||||
"devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||
log_info "Checking $comp service status..."
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "[RESULT]: $comp service is running."
|
||||
case_checked=false
|
||||
# devsvc, notification, content...
|
||||
if [ "$case_checked" = false ]; then
|
||||
for svc in "${ALL_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$svc" ]; then
|
||||
log_info "Checking $comp service status..."
|
||||
if [ -f "${WORKING_HOME}/.${comp}-instance" ]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
if docker ps --no-trunc --format '{{.ID}}' | grep -q "^${container_id}\$"; then
|
||||
log_info "[RESULT]: $comp service is running."
|
||||
else
|
||||
log_info "[RESULT]: $comp service is not running."
|
||||
fi
|
||||
else
|
||||
log_info "[RESULT]: $comp service is not running."
|
||||
fi
|
||||
else
|
||||
log_info "[RESULT]: $comp service is not running."
|
||||
case_checked=true
|
||||
break
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
# unknown
|
||||
if [ "$case_checked" = false ]; then
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
fi
|
||||
done
|
||||
|
||||
exit_with_message " DevBox services status checked successfully." 0
|
||||
}
|
||||
|
||||
@ -2870,77 +2878,100 @@ devbox_restart_command() {
|
||||
if [[ "$USE_LOCAL_COMPONENT" == "true" ]]; then
|
||||
log_info "Using local components..."
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("gitea" "mongodb" "rabbitmq" "devbox" "devsvc" "notification" "content" "central_storage" "chat" "authentication")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
COMPONENTS+=("${DEVBOX_COMPONENTS[@]}")
|
||||
else
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
else
|
||||
log_info "Using remote components..."
|
||||
if [[ -z "$COMPONENT" ]]; then
|
||||
COMPONENTS=("mongodb" "rabbitmq" "devbox")
|
||||
COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis" "devbox")
|
||||
else
|
||||
if [[ "$COMPONENT" == "devsvc" || "$COMPONENT" == "notification" || "$COMPONENT" == "content" || "$COMPONENT" == "central_storage" || "$COMPONENT" == "chat" || "$COMPONENT" == "authentication" ]]; then
|
||||
exit_with_message " Remote component $COMPONENT cannot be restarted, please use local components." 1
|
||||
found=false
|
||||
for item in "${DEVBOX_COMPONENTS[@]}"; do
|
||||
if [ "$item" = "$COMPONENT" ]; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" = true ]; then
|
||||
exit_with_message "Remote component $COMPONENT cannot be restarted, please use local components." 1
|
||||
fi
|
||||
|
||||
COMPONENTS=("$COMPONENT")
|
||||
fi
|
||||
fi
|
||||
|
||||
# Stop the specified components
|
||||
BASIC_COMPONENTS=("mongodb" "rabbitmq" "gitea" "redis")
|
||||
ALL_COMPONENTS=("${BASIC_COMPONENTS[@]}" "${DEVBOX_COMPONENTS[@]}" "devbox")
|
||||
|
||||
# Stop the specified components
|
||||
for comp in "${COMPONENTS[@]}"; do
|
||||
case "$comp" in
|
||||
"devbox")
|
||||
if [[ -f "${WORKING_HOME}/.devbox-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||
log_info "Stopping devbox service..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
|
||||
# Remove the frontend and backend pid files
|
||||
rm -f "${WORKING_HOME}/.backend.pid"
|
||||
rm -f "${WORKING_HOME}/.frontend.pid"
|
||||
else
|
||||
log_info "Devbox is not running."
|
||||
fi
|
||||
;;
|
||||
|
||||
"gitea" | "mongodb" | "rabbitmq" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
log_info "Stopping $comp service..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
;;
|
||||
esac
|
||||
if [ "$comp" = "devbox" ]; then
|
||||
if [ -f "${WORKING_HOME}/.devbox-instance" ]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.devbox-instance")
|
||||
log_info "Stopping devbox service..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
|
||||
rm -f "${WORKING_HOME}/.backend.pid"
|
||||
rm -f "${WORKING_HOME}/.frontend.pid"
|
||||
else
|
||||
log_info "Devbox is not running."
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
should_stop=false
|
||||
for known in "${BASIC_COMPONENTS[@]}" "${DEVBOX_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$known" ]; then
|
||||
should_stop=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$should_stop" = true ]; then
|
||||
if [ -f "${WORKING_HOME}/.${comp}-instance" ]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
log_info "Stopping $comp service..."
|
||||
docker stop "$container_id" &>/dev/null || true
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
else
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Start the specified components
|
||||
# Sleep 5 seconds to allow the services to stop, for each second echo 5 seconds increase from 1 to 5 in each second by -
|
||||
for comp in "${COMPONENTS[@]}"; do
|
||||
case "$comp" in
|
||||
"gitea" | "mongodb" | "rabbitmq" | "devbox" | "devsvc" | "notification" | "content" | "central_storage" | "chat" | "authentication")
|
||||
log_info "Restarting $comp service..."
|
||||
if [[ -f "${WORKING_HOME}/.${comp}-instance" ]]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
docker start "$container_id" &>/dev/null || true
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
;;
|
||||
esac
|
||||
is_known=false
|
||||
for known in "${ALL_COMPONENTS[@]}"; do
|
||||
if [ "$comp" = "$known" ]; then
|
||||
is_known=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$is_known" = true ]; then
|
||||
log_info "Restarting $comp service..."
|
||||
if [ -f "${WORKING_HOME}/.${comp}-instance" ]; then
|
||||
local container_id
|
||||
container_id=$(cat "${WORKING_HOME}/.${comp}-instance")
|
||||
docker start "$container_id" &>/dev/null || true
|
||||
else
|
||||
log_info "$comp service is not running."
|
||||
fi
|
||||
else
|
||||
exit_with_message " Unknown component: $comp, please check the component name." 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
exit_with_message " DevBox services restarted successfully." 0
|
||||
}
|
||||
|
||||
@ -3319,54 +3350,6 @@ devbox_init_parse_requirements() {
|
||||
add_arg '--devbox-image-tag' "devbox_local"
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--devsvc-image-tag')" ]; then
|
||||
if [ "$current_arch" == "arm64" ]; then
|
||||
add_arg '--devsvc-image-tag' "latest-linux-arm64"
|
||||
else
|
||||
add_arg '--devsvc-image-tag' "latest-linux-amd64"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--content-image-tag')" ]; then
|
||||
if [ "$current_arch" == "arm64" ]; then
|
||||
add_arg '--content-image-tag' "latest-linux-arm64"
|
||||
else
|
||||
add_arg '--content-image-tag' "latest-linux-amd64"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--central_storage-image-tag')" ]; then
|
||||
if [ "$current_arch" == "arm64" ]; then
|
||||
add_arg '--central_storage-image-tag' "latest-linux-arm64"
|
||||
else
|
||||
add_arg '--central_storage-image-tag' "latest-linux-amd64"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--chat-image-tag')" ]; then
|
||||
if [ "$current_arch" == "arm64" ]; then
|
||||
add_arg '--chat-image-tag' "latest-linux-arm64"
|
||||
else
|
||||
add_arg '--chat-image-tag' "latest-linux-amd64"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--notification-image-tag')" ]; then
|
||||
if [ "$current_arch" == "arm64" ]; then
|
||||
add_arg '--notification-image-tag' "latest-linux-arm64"
|
||||
else
|
||||
add_arg '--notification-image-tag' "latest-linux-amd64"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--authentication-image-tag')" ]; then
|
||||
if [ "$current_arch" == "arm64" ]; then
|
||||
add_arg '--authentication-image-tag' "latest-linux-arm64"
|
||||
else
|
||||
add_arg '--authentication-image-tag' "latest-linux-amd64"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(get_arg '--use-custom-repository')" ]; then
|
||||
add_arg '--use-custom-repository' ""
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user