#!/bin/bash set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR/.." echo "Starting local infrastructure..." docker compose -f infrastructure/docker-compose.yml up -d echo "Waiting for MySQL..." MAX_RETRIES=60 RETRY_COUNT=0 until docker exec mci-mysql mysql -uroot -proot -e "SELECT 1" > /dev/null 2>&1; do RETRY_COUNT=$((RETRY_COUNT + 1)) if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then echo "Error: MySQL did not become ready within ${MAX_RETRIES} seconds." >&2 exit 1 fi sleep 1 done echo "Waiting for Redis..." MAX_RETRIES=30 RETRY_COUNT=0 until docker exec mci-redis redis-cli ping | grep -q "PONG"; do RETRY_COUNT=$((RETRY_COUNT + 1)) if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then echo "Error: Redis did not become ready within ${MAX_RETRIES} seconds." >&2 exit 1 fi sleep 1 done echo "Waiting for RabbitMQ..." MAX_RETRIES=30 RETRY_COUNT=0 until curl -s -o /dev/null -w "%{http_code}" http://guest:guest@localhost:15672/api/overview | grep -q "200"; do RETRY_COUNT=$((RETRY_COUNT + 1)) if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then echo "Error: RabbitMQ did not become ready within ${MAX_RETRIES} seconds." >&2 exit 1 fi sleep 1 done echo "Local infrastructure is ready." echo "MySQL: jdbc:mysql://localhost:3306/sino_mci" echo "Redis: localhost:6379" echo "RabbitMQ: localhost:5672 / http://localhost:15672" echo "SeaweedFS: http://localhost:9333"