diff --git a/Makefile b/Makefile index 11c225c..46e9b4b 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ monitor: docker stats restart: - docker compose -p $(PROJECT_NAME) down && docker compose -p $(PROJECT_NAME) up -d + bash ./scripts/restart.sh show-restarts: @docker ps -q | while read id; do \ diff --git a/scripts/restart.sh b/scripts/restart.sh new file mode 100755 index 0000000..33d0fff --- /dev/null +++ b/scripts/restart.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# ============================================================================= +# restart.sh - Restart all services +# ============================================================================= +# Restarts all Docker Compose services including dynamically generated +# worker/runner compose files. +# +# Handles compose files: +# - docker-compose.yml (main) +# - docker-compose.n8n-workers.yml (if exists) +# +# Usage: bash scripts/restart.sh +# ============================================================================= + +set -e + +# Source the utilities file and initialize paths +source "$(dirname "$0")/utils.sh" +init_paths + +cd "$PROJECT_ROOT" + +PROJECT_NAME="localai" + +# Build compose files array +COMPOSE_FILES=("-f" "docker-compose.yml") + +# Add n8n workers compose file if exists +N8N_WORKERS_COMPOSE="docker-compose.n8n-workers.yml" +if [ -f "$N8N_WORKERS_COMPOSE" ]; then + COMPOSE_FILES+=("-f" "$N8N_WORKERS_COMPOSE") +fi + +log_info "Restarting services..." +log_info "Using compose files: ${COMPOSE_FILES[*]}" + +# Stop all services +docker compose -p "$PROJECT_NAME" "${COMPOSE_FILES[@]}" down + +# Start all services +docker compose -p "$PROJECT_NAME" "${COMPOSE_FILES[@]}" up -d + +log_success "Services restarted successfully!"