#!/bin/bash # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}๐Ÿ“Š Automated Development Pipeline Status${NC}" echo "======================================" # Check if we're in the right directory if [ ! -f "docker-compose.yml" ]; then echo -e "${RED}โŒ Error: docker-compose.yml not found. Please run from project root directory.${NC}" exit 1 fi # Detect Docker Compose command if command -v "docker" &> /dev/null && docker compose version &> /dev/null; then DOCKER_COMPOSE="docker compose" elif command -v docker-compose &> /dev/null; then DOCKER_COMPOSE="docker-compose" else echo -e "${RED}โŒ Docker Compose is not available.${NC}" exit 1 fi echo -e "${BLUE}๐Ÿณ Container Status:${NC}" echo "-------------------" $DOCKER_COMPOSE ps --format "table {{.Service}}\t{{.State}}\t{{.Status}}\t{{.Ports}}" echo "" echo -e "${BLUE}๐Ÿ’พ Storage Usage:${NC}" echo "----------------" docker system df --format "table {{.Type}}\t{{.TotalCount}}\t{{.Size}}\t{{.Reclaimable}}" echo "" echo -e "${BLUE}๐Ÿ” Service Health Checks:${NC}" echo "-------------------------" # Define services to check services=("postgres" "redis" "mongodb" "rabbitmq") ports=(5432 6379 27017 15672) health_commands=( "$DOCKER_COMPOSE exec -T postgres pg_isready -U pipeline_admin -d dev_pipeline" "$DOCKER_COMPOSE exec -T redis redis-cli ping" "$DOCKER_COMPOSE exec -T mongodb mongosh --eval 'db.runCommand(\"ping\").ok' --quiet" "$DOCKER_COMPOSE exec -T rabbitmq rabbitmq-diagnostics ping" ) for i in "${!services[@]}"; do service=${services[$i]} port=${ports[$i]} health_cmd=${health_commands[$i]} echo -n -e "${BLUE}$service:${NC} " # Check if container is running if $DOCKER_COMPOSE ps $service | grep -q "Up"; then echo -n -e "${GREEN}Running${NC}" # Check port accessibility if nc -z localhost $port 2>/dev/null; then echo -n -e " | ${GREEN}Port $port Open${NC}" else echo -n -e " | ${RED}Port $port Closed${NC}" fi # Check health if eval "$health_cmd" > /dev/null 2>&1; then echo -e " | ${GREEN}Healthy${NC}" else echo -e " | ${RED}Unhealthy${NC}" fi else echo -e "${RED}Stopped${NC}" fi done echo "" echo -e "${BLUE}๏ฟฝ๏ฟฝ Service Endpoints:${NC}" echo "--------------------" echo " ๐Ÿ˜ PostgreSQL: localhost:5432" echo " ๐Ÿ”ด Redis: localhost:6379" echo " ๐Ÿƒ MongoDB: localhost:27017" echo " ๐Ÿฐ RabbitMQ AMQP: localhost:5672" echo " ๐Ÿ“Š RabbitMQ Management: http://localhost:15672" echo "" echo -e "${BLUE}๐Ÿ”— Quick Connection Tests:${NC}" echo "--------------------------" # PostgreSQL test echo -n -e "${BLUE}PostgreSQL:${NC} " if $DOCKER_COMPOSE exec -T postgres psql -U pipeline_admin -d dev_pipeline -c "SELECT 1;" > /dev/null 2>&1; then echo -e "${GREEN}โœ… Connection successful${NC}" else echo -e "${RED}โŒ Connection failed${NC}" fi # Redis test echo -n -e "${BLUE}Redis:${NC} " redis_response=$($DOCKER_COMPOSE exec -T redis redis-cli ping 2>/dev/null) if [[ "$redis_response" == *"PONG"* ]]; then echo -e "${GREEN}โœ… Connection successful${NC}" else echo -e "${RED}โŒ Connection failed${NC}" fi # MongoDB test echo -n -e "${BLUE}MongoDB:${NC} " if $DOCKER_COMPOSE exec -T mongodb mongosh --eval "db.runCommand('ping')" --quiet > /dev/null 2>&1; then echo -e "${GREEN}โœ… Connection successful${NC}" else echo -e "${RED}โŒ Connection failed${NC}" fi # RabbitMQ test echo -n -e "${BLUE}RabbitMQ:${NC} " if $DOCKER_COMPOSE exec -T rabbitmq rabbitmq-diagnostics ping > /dev/null 2>&1; then echo -e "${GREEN}โœ… Connection successful${NC}" else echo -e "${RED}โŒ Connection failed${NC}" fi # RabbitMQ Management UI test echo -n -e "${BLUE}RabbitMQ Management:${NC} " if curl -s -u pipeline_admin:rabbit_secure_2024 http://localhost:15672/api/overview > /dev/null 2>&1; then echo -e "${GREEN}โœ… Management UI accessible${NC}" else echo -e "${RED}โŒ Management UI not accessible${NC}" fi echo "" echo -e "${BLUE}๐Ÿ”ง Management Commands:${NC}" echo "----------------------" echo " ๐Ÿš€ Start services: ./scripts/setup/start.sh" echo " ๐Ÿ›‘ Stop services: ./scripts/setup/stop.sh" echo " ๐Ÿ“‹ View logs: $DOCKER_COMPOSE logs [service-name]" echo " ๐Ÿ”„ Restart service: $DOCKER_COMPOSE restart [service-name]" echo " ๐Ÿงช Test RabbitMQ: python3 scripts/rabbitmq/test-queues.py" echo ""