|
1 | 1 | # DispatchAI Development Makefile |
2 | 2 | # Provides targets for development, testing, linting, and deployment |
3 | 3 |
|
4 | | -.PHONY: help dev dev-up dev-down dev-logs dev-clean test test-docker test-ingress test-classifier test-gateway test-dashboard test-classifier-docker test-gateway-docker test-dashboard-docker lint lint-python lint-python-docker lint-js clean build setup-env check-env check-containers test-webhook-manual kafka-tail |
| 4 | +.PHONY: help dev dev-up dev-down dev-logs dev-clean test test-docker test-ingress test-classifier test-gateway test-dashboard test-classifier-docker test-gateway-docker test-dashboard-docker lint lint-python lint-python-docker lint-js clean build setup-env check-env check-containers test-webhook-manual demo kafka-tail health health-ingress health-classifier health-gateway metrics metrics-ingress metrics-classifier metrics-gateway metrics-summary watch-metrics system-status |
5 | 5 |
|
6 | 6 | # Default target |
7 | 7 | help: ## Show this help message |
@@ -48,24 +48,116 @@ dev-clean: ## Stop services and remove volumes/networks |
48 | 48 | @echo "Pruning unused Docker resources..." |
49 | 49 | docker system prune -f |
50 | 50 |
|
51 | | -# Health Checks |
| 51 | +# Health Checks & Metrics |
52 | 52 | check-services: ## Check if all services are healthy |
53 | 53 | @echo "Checking service health..." |
54 | | - @echo -n "PostgreSQL: " |
55 | | - @docker exec dispatchai-postgres pg_isready -U postgres >/dev/null 2>&1 && echo "✅ Ready" || echo "❌ Not Ready" |
56 | | - @echo -n "Redpanda: " |
57 | | - @curl -s http://localhost:9644/v1/cluster/health >/dev/null 2>&1 && echo "✅ Ready" || echo "❌ Not Ready" |
| 54 | + @printf "PostgreSQL: " && docker exec dispatchai-postgres pg_isready -U postgres >/dev/null 2>&1 && echo "✅ Ready" || echo "❌ Not Ready" |
| 55 | + @printf "Redpanda: " && curl -s http://localhost:9644/v1/cluster/health >/dev/null 2>&1 && echo "✅ Ready" || echo "❌ Not Ready" |
58 | 56 |
|
59 | 57 | check-containers: ## Check if all containers are running |
60 | 58 | @echo "Checking containers..." |
61 | | - @echo -n "Ingress: " |
62 | | - @docker ps --format "table {{.Names}}" | grep -q "dispatchai-ingress" && echo "✅ Running" || echo "❌ Not Running" |
63 | | - @echo -n "Classifier: " |
64 | | - @docker ps --format "table {{.Names}}" | grep -q "dispatchai-classifier" && echo "✅ Running" || echo "❌ Not Running" |
65 | | - @echo -n "Gateway: " |
66 | | - @docker ps --format "table {{.Names}}" | grep -q "dispatchai-gateway" && echo "✅ Running" || echo "❌ Not Running" |
67 | | - @echo -n "Dashboard: " |
68 | | - @docker ps --format "table {{.Names}}" | grep -q "dispatchai-dashboard" && echo "✅ Running" || echo "❌ Not Running" |
| 59 | + @printf "Ingress: " && docker ps --format "table {{.Names}}" | grep -q "dispatchai-ingress" && echo "✅ Running" || echo "❌ Not Running" |
| 60 | + @printf "Classifier: " && docker ps --format "table {{.Names}}" | grep -q "dispatchai-classifier" && echo "✅ Running" || echo "❌ Not Running" |
| 61 | + @printf "Gateway: " && docker ps --format "table {{.Names}}" | grep -q "dispatchai-gateway" && echo "✅ Running" || echo "❌ Not Running" |
| 62 | + @printf "Dashboard: " && docker ps --format "table {{.Names}}" | grep -q "dispatchai-dashboard" && echo "✅ Running" || echo "❌ Not Running" |
| 63 | + |
| 64 | +health: ## Show detailed health status of all services |
| 65 | + @echo "======================================" |
| 66 | + @echo "DispatchAI System Health Report" |
| 67 | + @echo "======================================" |
| 68 | + @echo "" |
| 69 | + @echo "📊 Ingress Service (Port 8000):" |
| 70 | + @curl -s http://localhost:8000/health 2>/dev/null | python3 -m json.tool || echo "❌ Service unreachable" |
| 71 | + @echo "" |
| 72 | + @echo "🤖 Classifier Service (Port 8001):" |
| 73 | + @curl -s http://localhost:8001/health 2>/dev/null | python3 -m json.tool || echo "❌ Service unreachable" |
| 74 | + @echo "" |
| 75 | + @echo "🔗 Gateway Service (Port 8002):" |
| 76 | + @curl -s http://localhost:8002/health 2>/dev/null | python3 -m json.tool || echo "❌ Service unreachable" |
| 77 | + @echo "" |
| 78 | + |
| 79 | +health-ingress: ## Show health status of ingress service |
| 80 | + @echo "Ingress Service Health:" |
| 81 | + @curl -s http://localhost:8000/health | python3 -m json.tool |
| 82 | + |
| 83 | +health-classifier: ## Show health status of classifier service |
| 84 | + @echo "Classifier Service Health:" |
| 85 | + @curl -s http://localhost:8001/health | python3 -m json.tool |
| 86 | + |
| 87 | +health-gateway: ## Show health status of gateway service |
| 88 | + @echo "Gateway Service Health:" |
| 89 | + @curl -s http://localhost:8002/health | python3 -m json.tool |
| 90 | + |
| 91 | +metrics: ## Show comprehensive metrics from all services |
| 92 | + @echo "======================================" |
| 93 | + @echo "DispatchAI System Metrics Report" |
| 94 | + @echo "======================================" |
| 95 | + @echo "" |
| 96 | + @echo "📊 Ingress Service Metrics:" |
| 97 | + @curl -s http://localhost:8000/metrics 2>/dev/null | python3 -m json.tool || echo "❌ Metrics unavailable" |
| 98 | + @echo "" |
| 99 | + @echo "🤖 Classifier Service Metrics:" |
| 100 | + @curl -s http://localhost:8001/metrics 2>/dev/null | python3 -m json.tool || echo "❌ Metrics unavailable" |
| 101 | + @echo "" |
| 102 | + @echo "🔗 Gateway Service Metrics:" |
| 103 | + @curl -s http://localhost:8002/metrics 2>/dev/null | python3 -m json.tool || echo "❌ Metrics unavailable" |
| 104 | + @echo "" |
| 105 | + @echo "📡 Kafka Consumer Lag:" |
| 106 | + @docker exec dispatchai-redpanda rpk group describe dispatchai-classifier 2>/dev/null || echo "❌ Consumer group not found" |
| 107 | + @echo "" |
| 108 | + |
| 109 | +metrics-ingress: ## Show metrics for ingress service |
| 110 | + @echo "Ingress Service Metrics:" |
| 111 | + @curl -s http://localhost:8000/metrics | python3 -m json.tool |
| 112 | + |
| 113 | +metrics-classifier: ## Show metrics for classifier service |
| 114 | + @echo "Classifier Service Metrics:" |
| 115 | + @curl -s http://localhost:8001/metrics | python3 -m json.tool |
| 116 | + |
| 117 | +metrics-gateway: ## Show metrics for gateway service |
| 118 | + @echo "Gateway Service Metrics:" |
| 119 | + @curl -s http://localhost:8002/metrics | python3 -m json.tool |
| 120 | + |
| 121 | +metrics-summary: ## Show quick metrics summary (perfect for demos) |
| 122 | + @echo "======================================" |
| 123 | + @echo "📊 DispatchAI Metrics Summary" |
| 124 | + @echo "======================================" |
| 125 | + @echo "" |
| 126 | + @echo "Ingress (Webhook Processing):" |
| 127 | + @curl -s http://localhost:8000/metrics 2>/dev/null | python3 -c "import sys, json; d=json.load(sys.stdin); print(f\" Webhooks Received: {d.get('webhooks_received', 0)}\"); print(f\" Webhooks Accepted: {d.get('webhooks_accepted', 0)}\"); print(f\" Processing Time (p95): {d.get('processing_time_ms', {}).get('p95', 'N/A')}ms\"); print(f\" Uptime: {d.get('uptime_seconds', 0)}s\")" || echo " ❌ Unavailable" |
| 128 | + @echo "" |
| 129 | + @echo "Classifier (AI Processing):" |
| 130 | + @curl -s http://localhost:8001/metrics 2>/dev/null | python3 -c "import sys, json; d=json.load(sys.stdin); print(f\" Issues Processed: {d.get('issues_processed', 0)}\"); print(f\" Classification Time (p95): {d.get('classification_time_ms', {}).get('p95', 'N/A')}ms\"); print(f\" OpenAI Errors: {d.get('openai_api_errors', 0)}\"); print(f\" Consumer Lag: {d.get('consumer_lag', 0)}\"); print(f\" Uptime: {d.get('uptime_seconds', 0)}s\")" || echo " ❌ Unavailable" |
| 131 | + @echo "" |
| 132 | + @echo "Gateway (WebSocket Streaming):" |
| 133 | + @curl -s http://localhost:8002/metrics 2>/dev/null | python3 -c "import sys, json; d=json.load(sys.stdin); print(f\" Active WebSocket Connections: {d.get('websocket_connections_active', 0)}\"); print(f\" Messages Broadcast: {d.get('messages_broadcast', 0)}\"); print(f\" API Requests: {d.get('api_requests', 0)}\"); print(f\" Uptime: {d.get('uptime_seconds', 0)}s\")" || echo " ❌ Unavailable" |
| 134 | + @echo "" |
| 135 | + |
| 136 | +watch-metrics: ## Watch metrics in real-time (refreshes every 3 seconds) |
| 137 | + @echo "Watching metrics (Ctrl+C to stop)..." |
| 138 | + @while true; do \ |
| 139 | + clear; \ |
| 140 | + make metrics-summary; \ |
| 141 | + sleep 3; \ |
| 142 | + done |
| 143 | + |
| 144 | +system-status: ## Show complete system status (containers + health + metrics) |
| 145 | + @echo "======================================" |
| 146 | + @echo "🚀 DispatchAI System Status Report" |
| 147 | + @echo "======================================" |
| 148 | + @echo "" |
| 149 | + @echo "📦 Container Status:" |
| 150 | + @make check-containers |
| 151 | + @echo "" |
| 152 | + @echo "💚 Service Health:" |
| 153 | + @make check-services |
| 154 | + @echo "" |
| 155 | + @echo "📈 Performance Metrics:" |
| 156 | + @make metrics-summary |
| 157 | + @echo "" |
| 158 | + @echo "======================================" |
| 159 | + @echo "✅ System Status Report Complete" |
| 160 | + @echo "======================================" |
69 | 161 |
|
70 | 162 | # Testing |
71 | 163 | test: ## Run all tests (requires running containers) |
@@ -176,6 +268,14 @@ test-webhook-manual: ## Run manual webhook testing script |
176 | 268 | echo "❌ Manual test script not found at scripts/test-webhook-manual.sh"; \ |
177 | 269 | fi |
178 | 270 |
|
| 271 | +demo: ## Run comprehensive system showcase demo (perfect for interviews!) |
| 272 | + @echo "🎯 Running DispatchAI System Showcase Demo..." |
| 273 | + @if [ -f scripts/demo-system-showcase.sh ]; then \ |
| 274 | + ./scripts/demo-system-showcase.sh; \ |
| 275 | + else \ |
| 276 | + echo "❌ Demo script not found at scripts/demo-system-showcase.sh"; \ |
| 277 | + fi |
| 278 | + |
179 | 279 | # Linting |
180 | 280 | lint: ## Run all linters |
181 | 281 | @echo "Running all linters..." |
|
0 commit comments