Fix hardcoded paths and improve start_hive.sh script
- Replace hardcoded HIVE_ROOT with dynamic path resolution - Fix docker-compose.yml reference to use docker-compose.swarm.yml - Add proper error handling for docker commands - Replace fragile sleep with proper health check loops - Update service health checks for docker swarm - Fix service URLs to use HTTPS endpoints - Add all 6 agents to connectivity tests - Update management commands for docker stack operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
HIVE_ROOT="/home/tony/AI/projects/hive"
|
# Use relative path or environment variable
|
||||||
|
HIVE_ROOT="${HIVE_ROOT:-$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")}"
|
||||||
LOG_FILE="$HIVE_ROOT/logs/startup.log"
|
LOG_FILE="$HIVE_ROOT/logs/startup.log"
|
||||||
|
|
||||||
# Colors for output
|
# Colors for output
|
||||||
@@ -78,40 +79,79 @@ fi
|
|||||||
|
|
||||||
log_success "docker compose is available"
|
log_success "docker compose is available"
|
||||||
|
|
||||||
|
# Check if docker-compose.swarm.yml exists
|
||||||
|
if [ ! -f "$HIVE_ROOT/docker-compose.swarm.yml" ]; then
|
||||||
|
log_error "docker-compose.swarm.yml not found in $HIVE_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Pull latest images
|
# Pull latest images
|
||||||
log_info "Pulling latest base images..."
|
log_info "Pulling latest base images..."
|
||||||
docker compose pull postgres redis prometheus grafana
|
if docker compose -f docker-compose.swarm.yml pull postgres redis prometheus grafana; then
|
||||||
|
log_success "Base images pulled successfully"
|
||||||
|
else
|
||||||
|
log_error "Failed to pull base images"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Build Hive services
|
# Build Hive services
|
||||||
log_info "Building Hive services..."
|
log_info "Building Hive services..."
|
||||||
if docker compose build; then
|
if docker build -t anthonyrawlins/hive-backend:latest ./backend && docker build -t anthonyrawlins/hive-frontend:latest ./frontend; then
|
||||||
log_success "Hive services built successfully"
|
log_success "Hive services built successfully"
|
||||||
else
|
else
|
||||||
log_error "Failed to build Hive services"
|
log_error "Failed to build Hive services"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start services
|
# Deploy services using docker stack
|
||||||
log_info "Starting Hive services..."
|
log_info "Deploying Hive services..."
|
||||||
if docker compose up -d; then
|
if docker stack deploy -c docker-compose.swarm.yml hive; then
|
||||||
log_success "Hive services started successfully"
|
log_success "Hive services deployed successfully"
|
||||||
else
|
else
|
||||||
log_error "Failed to start Hive services"
|
log_error "Failed to deploy Hive services"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for services to be ready
|
# Wait for services to be ready with proper health checks
|
||||||
log_info "Waiting for services to be ready..."
|
log_info "Waiting for services to be ready..."
|
||||||
sleep 10
|
wait_for_service() {
|
||||||
|
local service=$1
|
||||||
|
local url=$2
|
||||||
|
local timeout=60
|
||||||
|
local count=0
|
||||||
|
|
||||||
# Check service health
|
while [ $count -lt $timeout ]; do
|
||||||
|
if timeout 5 curl -s "$url" &> /dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
count=$((count + 2))
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wait for backend API
|
||||||
|
if wait_for_service "hive-backend" "http://localhost:8000/health"; then
|
||||||
|
log_success "Backend API is ready"
|
||||||
|
else
|
||||||
|
log_warning "Backend API not responding after 60 seconds"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wait for frontend
|
||||||
|
if wait_for_service "hive-frontend" "http://localhost:3000"; then
|
||||||
|
log_success "Frontend is ready"
|
||||||
|
else
|
||||||
|
log_warning "Frontend not responding after 60 seconds"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check service health using docker stack
|
||||||
log_info "Checking service health..."
|
log_info "Checking service health..."
|
||||||
|
|
||||||
services=("postgres" "redis" "hive-backend" "hive-frontend" "prometheus" "grafana")
|
services=("hive_postgres" "hive_redis" "hive_hive-backend" "hive_hive-frontend" "hive_prometheus" "hive_grafana")
|
||||||
healthy_services=0
|
healthy_services=0
|
||||||
|
|
||||||
for service in "${services[@]}"; do
|
for service in "${services[@]}"; do
|
||||||
if docker compose ps "$service" | grep -q "Up"; then
|
if docker service ls --filter "name=$service" --format "{{.Replicas}}" | grep -q "1/1"; then
|
||||||
log_success "$service is running"
|
log_success "$service is running"
|
||||||
((healthy_services++))
|
((healthy_services++))
|
||||||
else
|
else
|
||||||
@@ -127,11 +167,11 @@ fi
|
|||||||
|
|
||||||
# Display service URLs
|
# Display service URLs
|
||||||
echo -e "\n${CYAN}🔗 Service URLs:${NC}"
|
echo -e "\n${CYAN}🔗 Service URLs:${NC}"
|
||||||
echo -e "${GREEN} • Hive Frontend:${NC} http://localhost:3000"
|
echo -e "${GREEN} • Hive Frontend:${NC} https://hive.home.deepblack.cloud"
|
||||||
echo -e "${GREEN} • Hive API:${NC} http://localhost:8000"
|
echo -e "${GREEN} • Hive API:${NC} https://hive-api.home.deepblack.cloud"
|
||||||
echo -e "${GREEN} • API Documentation:${NC} http://localhost:8000/docs"
|
echo -e "${GREEN} • API Documentation:${NC} https://hive-api.home.deepblack.cloud/docs"
|
||||||
echo -e "${GREEN} • Grafana Dashboard:${NC} http://localhost:3001 (admin/hiveadmin)"
|
echo -e "${GREEN} • Grafana Dashboard:${NC} https://hive-grafana.home.deepblack.cloud (admin/hiveadmin)"
|
||||||
echo -e "${GREEN} • Prometheus:${NC} http://localhost:9090"
|
echo -e "${GREEN} • Prometheus:${NC} https://hive-prometheus.home.deepblack.cloud"
|
||||||
echo -e "${GREEN} • PostgreSQL:${NC} localhost:5432 (hive/hivepass)"
|
echo -e "${GREEN} • PostgreSQL:${NC} localhost:5432 (hive/hivepass)"
|
||||||
echo -e "${GREEN} • Redis:${NC} localhost:6379"
|
echo -e "${GREEN} • Redis:${NC} localhost:6379"
|
||||||
|
|
||||||
@@ -146,18 +186,18 @@ echo -e "${GREEN} • TULLY:${NC} http://Tullys-MacBook-Air.local:11434 (Mo
|
|||||||
|
|
||||||
# Display next steps
|
# Display next steps
|
||||||
echo -e "\n${PURPLE}📋 Next Steps:${NC}"
|
echo -e "\n${PURPLE}📋 Next Steps:${NC}"
|
||||||
echo -e "${YELLOW} 1.${NC} Open Hive Dashboard: ${BLUE}http://localhost:3000${NC}"
|
echo -e "${YELLOW} 1.${NC} Open Hive Dashboard: ${BLUE}https://hive.home.deepblack.cloud${NC}"
|
||||||
echo -e "${YELLOW} 2.${NC} Check agent connectivity in the dashboard"
|
echo -e "${YELLOW} 2.${NC} Check agent connectivity in the dashboard"
|
||||||
echo -e "${YELLOW} 3.${NC} Import or create your first workflow"
|
echo -e "${YELLOW} 3.${NC} Import or create your first workflow"
|
||||||
echo -e "${YELLOW} 4.${NC} Monitor execution in real-time"
|
echo -e "${YELLOW} 4.${NC} Monitor execution in real-time"
|
||||||
echo -e "${YELLOW} 5.${NC} View metrics in Grafana: ${BLUE}http://localhost:3001${NC}"
|
echo -e "${YELLOW} 5.${NC} View metrics in Grafana: ${BLUE}https://hive-grafana.home.deepblack.cloud${NC}"
|
||||||
|
|
||||||
# Display management commands
|
# Display management commands
|
||||||
echo -e "\n${PURPLE}🛠️ Management Commands:${NC}"
|
echo -e "\n${PURPLE}🛠️ Management Commands:${NC}"
|
||||||
echo -e "${YELLOW} • View logs:${NC} docker compose logs -f"
|
echo -e "${YELLOW} • View logs:${NC} docker service logs hive_hive-backend"
|
||||||
echo -e "${YELLOW} • Stop services:${NC} docker compose down"
|
echo -e "${YELLOW} • Stop services:${NC} docker stack rm hive"
|
||||||
echo -e "${YELLOW} • Restart:${NC} docker compose restart"
|
echo -e "${YELLOW} • Restart:${NC} docker stack rm hive && docker stack deploy -c docker-compose.swarm.yml hive"
|
||||||
echo -e "${YELLOW} • Shell access:${NC} docker compose exec hive-backend bash"
|
echo -e "${YELLOW} • Shell access:${NC} docker exec -it \$(docker ps -q -f name=hive_hive-backend) bash"
|
||||||
|
|
||||||
# Check agent connectivity
|
# Check agent connectivity
|
||||||
echo -e "\n${CYAN}🔍 Testing Agent Connectivity:${NC}"
|
echo -e "\n${CYAN}🔍 Testing Agent Connectivity:${NC}"
|
||||||
@@ -166,6 +206,9 @@ agents=(
|
|||||||
"ACACIA:192.168.1.72:11434"
|
"ACACIA:192.168.1.72:11434"
|
||||||
"WALNUT:192.168.1.27:11434"
|
"WALNUT:192.168.1.27:11434"
|
||||||
"IRONWOOD:192.168.1.113:11434"
|
"IRONWOOD:192.168.1.113:11434"
|
||||||
|
"ROSEWOOD:192.168.1.132:11434"
|
||||||
|
"OAK:oak.local:11434"
|
||||||
|
"TULLY:Tullys-MacBook-Air.local:11434"
|
||||||
)
|
)
|
||||||
|
|
||||||
for agent_info in "${agents[@]}"; do
|
for agent_info in "${agents[@]}"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user