mirror of
https://github.com/kossakovsky/n8n-install.git
synced 2026-03-07 22:33:11 +00:00
Refactor service management in start_services.py and scripts
- Updated the is_supabase_enabled function to read COMPOSE_PROFILES from the .env file instead of os.environ, improving clarity. - Simplified the run_command function by removing the unused env parameter. - Refined the stop_existing_containers function to streamline the shutdown process for the 'localai' project, conditionally including the Supabase compose file. - Enhanced logging for better user feedback during service management operations. - Adjusted the scripts for generating secrets and applying updates to improve clarity and functionality.
This commit is contained in:
@@ -187,19 +187,8 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# Determine N8N_WORKFLOWS_IMPORTED_EVER based on RUN_N8N_IMPORT and existing values
|
||||
N8N_WORKFLOWS_IMPORTED_EVER_VALUE="false" # Default to false
|
||||
if [[ -n "${existing_env_vars[N8N_WORKFLOWS_IMPORTED_EVER]}" ]]; then
|
||||
N8N_WORKFLOWS_IMPORTED_EVER_VALUE="${existing_env_vars[N8N_WORKFLOWS_IMPORTED_EVER]}"
|
||||
log_info "Using existing N8N_WORKFLOWS_IMPORTED_EVER value from .env: $N8N_WORKFLOWS_IMPORTED_EVER_VALUE"
|
||||
else
|
||||
# If N8N_WORKFLOWS_IMPORTED_EVER is not in .env, set it based on RUN_N8N_IMPORT choice
|
||||
if [[ "$RUN_N8N_IMPORT" == "true" ]]; then
|
||||
N8N_WORKFLOWS_IMPORTED_EVER_VALUE="true"
|
||||
fi
|
||||
# No else needed, it's already defaulted to false
|
||||
log_info "Setting N8N_WORKFLOWS_IMPORTED_EVER based on current import choice (or default): $N8N_WORKFLOWS_IMPORTED_EVER_VALUE"
|
||||
fi
|
||||
# Set N8N_WORKFLOWS_IMPORTED_EVER_VALUE based on RUN_N8N_IMPORT
|
||||
N8N_WORKFLOWS_IMPORTED_EVER_VALUE="$RUN_N8N_IMPORT"
|
||||
|
||||
# Prompt for number of n8n workers
|
||||
echo "" # Add a newline for better formatting
|
||||
|
||||
@@ -28,15 +28,35 @@ fi
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# Stop all services
|
||||
log_info "Stopping all services..."
|
||||
$COMPOSE_CMD down || {
|
||||
log_warning "Failed to stop containers with 'docker compose down'. Continuing with update anyway...";
|
||||
}
|
||||
# Stop all services for project 'localai'
|
||||
log_info "Stopping all services for project 'localai'..."
|
||||
PROJECT_CONTAINERS=$(docker ps -a -q --filter "label=com.docker.compose.project=localai")
|
||||
if [ -n "$PROJECT_CONTAINERS" ]; then
|
||||
docker stop $PROJECT_CONTAINERS || log_warning "Some containers for project 'localai' failed to stop."
|
||||
docker rm $PROJECT_CONTAINERS || log_warning "Some containers for project 'localai' failed to be removed."
|
||||
else
|
||||
log_info "No containers found for project 'localai' to stop/remove."
|
||||
fi
|
||||
|
||||
# Pull latest versions of all containers
|
||||
log_info "Pulling latest versions of all containers..."
|
||||
$COMPOSE_CMD pull || { log_error "Failed to pull Docker images. Check network connection and Docker Hub status."; exit 1; }
|
||||
# Pull latest versions of all potentially needed containers
|
||||
log_info "Pulling latest versions of all potentially needed containers..."
|
||||
COMPOSE_FILES_FOR_PULL=("-f" "$PROJECT_ROOT/docker-compose.yml")
|
||||
SUPABASE_DOCKER_DIR="$PROJECT_ROOT/supabase/docker"
|
||||
SUPABASE_COMPOSE_FILE_PATH="$SUPABASE_DOCKER_DIR/docker-compose.yml"
|
||||
|
||||
# Check if Supabase directory and its docker-compose.yml exist
|
||||
if [ -d "$SUPABASE_DOCKER_DIR" ] && [ -f "$SUPABASE_COMPOSE_FILE_PATH" ]; then
|
||||
COMPOSE_FILES_FOR_PULL+=("-f" "$SUPABASE_COMPOSE_FILE_PATH")
|
||||
log_info "Supabase docker-compose.yml found, will be included in pull."
|
||||
else
|
||||
log_info "Supabase docker-compose.yml not found or directory does not exist, skipping for pull."
|
||||
fi
|
||||
|
||||
# Use the project name "localai" for consistency
|
||||
$COMPOSE_CMD -p "localai" "${COMPOSE_FILES_FOR_PULL[@]}" pull --ignore-buildable || {
|
||||
log_error "Failed to pull Docker images. Check network connection and Docker Hub status."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Run Service Selection Wizard ---
|
||||
log_info "Running Service Selection Wizard to update service choices..."
|
||||
|
||||
Reference in New Issue
Block a user