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