Agent 106: ML health endpoint (HTTP/8095) Agent 107: Redis test fix (serial_test isolation) Agent 108: CLAUDE.md draft update (95-97% → 100%) Agent 109: Prometheus/Grafana setup (31 alerts, 6 dashboards) Agent 110: Deployment docs (9 files + 4 scripts) Agent 111: Security audit prep (0 critical vulnerabilities) Service Health: 4/4 healthy (100%) Tests: 99%+ pass rate Production: ~98% readiness Next: Wave 2 (E2E, load, perf, security validation)
161 lines
6.1 KiB
Bash
Executable File
161 lines
6.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Foxhunt HFT System - Service Dependency Checker
|
|
# Verifies the complete service dependency chain
|
|
|
|
# Color codes
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo "================================================================================"
|
|
echo " Foxhunt Service Dependencies - Health Check"
|
|
echo "================================================================================"
|
|
echo "Timestamp: $(date '+%Y-%m-%d %H:%M:%S')"
|
|
echo ""
|
|
|
|
# Function to check and display status
|
|
check_status() {
|
|
local component=$1
|
|
local check_cmd=$2
|
|
|
|
echo -n " $component: "
|
|
if eval "$check_cmd" > /dev/null 2>&1; then
|
|
echo -e "${GREEN}✓${NC}"
|
|
return 0
|
|
else
|
|
echo -e "${RED}✗${NC}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Layer 1: Infrastructure
|
|
echo -e "${BLUE}[Layer 1: Infrastructure]${NC}"
|
|
check_status "PostgreSQL " "docker exec foxhunt-postgres pg_isready -U foxhunt"
|
|
check_status "Redis " "docker exec foxhunt-redis redis-cli ping | grep -q PONG"
|
|
check_status "Vault " "curl -sf http://localhost:8200/v1/sys/health"
|
|
check_status "InfluxDB " "curl -sf http://localhost:8086/health"
|
|
echo ""
|
|
|
|
# Layer 2: Core Services
|
|
echo -e "${BLUE}[Layer 2: Core Services]${NC}"
|
|
check_status "Trading Service " "curl -sf http://localhost:8081/health"
|
|
check_status "Backtesting Svc " "curl -sf http://localhost:8083/health"
|
|
check_status "ML Training Svc " "curl -sf http://localhost:8095/health"
|
|
echo ""
|
|
|
|
# Layer 3: Gateway
|
|
echo -e "${BLUE}[Layer 3: Gateway]${NC}"
|
|
if command -v grpc_health_probe &> /dev/null; then
|
|
check_status "API Gateway " "grpc_health_probe -addr=localhost:50051"
|
|
else
|
|
check_status "API Gateway " "curl -sf http://localhost:8080/health"
|
|
fi
|
|
echo ""
|
|
|
|
# Layer 4: Monitoring (Optional)
|
|
echo -e "${BLUE}[Layer 4: Monitoring - Optional]${NC}"
|
|
check_status "Prometheus " "curl -sf http://localhost:9090/-/healthy"
|
|
check_status "Grafana " "curl -sf http://localhost:3000/api/health"
|
|
echo ""
|
|
|
|
# Dependency Chain Validation
|
|
echo -e "${BLUE}[Dependency Chain Validation]${NC}"
|
|
|
|
# API Gateway → PostgreSQL
|
|
if docker exec foxhunt-postgres pg_isready -U foxhunt > /dev/null 2>&1 && curl -sf http://localhost:8080/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} API Gateway → PostgreSQL"
|
|
else
|
|
echo -e " ${RED}✗${NC} API Gateway → PostgreSQL"
|
|
fi
|
|
|
|
# API Gateway → Redis
|
|
if docker exec foxhunt-redis redis-cli ping | grep -q PONG 2>/dev/null && curl -sf http://localhost:8080/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} API Gateway → Redis"
|
|
else
|
|
echo -e " ${RED}✗${NC} API Gateway → Redis"
|
|
fi
|
|
|
|
# API Gateway → Trading Service
|
|
if curl -sf http://localhost:8081/health > /dev/null 2>&1 && curl -sf http://localhost:8080/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} API Gateway → Trading Service"
|
|
else
|
|
echo -e " ${RED}✗${NC} API Gateway → Trading Service"
|
|
fi
|
|
|
|
# Trading Service → PostgreSQL
|
|
if docker exec foxhunt-postgres pg_isready -U foxhunt > /dev/null 2>&1 && curl -sf http://localhost:8081/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} Trading Service → PostgreSQL"
|
|
else
|
|
echo -e " ${RED}✗${NC} Trading Service → PostgreSQL"
|
|
fi
|
|
|
|
# Trading Service → Redis
|
|
if docker exec foxhunt-redis redis-cli ping | grep -q PONG 2>/dev/null && curl -sf http://localhost:8081/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} Trading Service → Redis"
|
|
else
|
|
echo -e " ${RED}✗${NC} Trading Service → Redis"
|
|
fi
|
|
|
|
# Backtesting Service → PostgreSQL
|
|
if docker exec foxhunt-postgres pg_isready -U foxhunt > /dev/null 2>&1 && curl -sf http://localhost:8083/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} Backtesting Service → PostgreSQL"
|
|
else
|
|
echo -e " ${RED}✗${NC} Backtesting Service → PostgreSQL"
|
|
fi
|
|
|
|
# ML Training Service → PostgreSQL
|
|
if docker exec foxhunt-postgres pg_isready -U foxhunt > /dev/null 2>&1 && curl -sf http://localhost:8095/health > /dev/null 2>&1; then
|
|
echo -e " ${GREEN}✓${NC} ML Training Service → PostgreSQL"
|
|
else
|
|
echo -e " ${RED}✗${NC} ML Training Service → PostgreSQL"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Database Connection Pool Status
|
|
echo -e "${BLUE}[Database Connection Pool Status]${NC}"
|
|
if docker exec foxhunt-postgres psql -U foxhunt -d foxhunt -c 'SELECT count(*) as connections FROM pg_stat_activity;' 2>/dev/null | grep -q "connections"; then
|
|
CONN_COUNT=$(docker exec foxhunt-postgres psql -U foxhunt -d foxhunt -t -c 'SELECT count(*) FROM pg_stat_activity;' 2>/dev/null | tr -d ' ')
|
|
echo -e " Active PostgreSQL connections: ${CONN_COUNT}"
|
|
else
|
|
echo -e " ${RED}Unable to query PostgreSQL connection pool${NC}"
|
|
fi
|
|
|
|
# Redis Memory Status
|
|
if docker exec foxhunt-redis redis-cli INFO memory 2>/dev/null | grep -q "used_memory_human"; then
|
|
REDIS_MEM=$(docker exec foxhunt-redis redis-cli INFO memory 2>/dev/null | grep used_memory_human | cut -d: -f2 | tr -d '\r')
|
|
REDIS_KEYS=$(docker exec foxhunt-redis redis-cli DBSIZE 2>/dev/null | awk '{print $2}')
|
|
echo -e " Redis memory usage: ${REDIS_MEM} (${REDIS_KEYS} keys)"
|
|
else
|
|
echo -e " ${RED}Unable to query Redis status${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Port Listening Status
|
|
echo -e "${BLUE}[Port Listening Status]${NC}"
|
|
echo " Service Ports:"
|
|
netstat -tulpn 2>/dev/null | grep LISTEN | grep -E ":(50051|50052|50053|50054|5432|6379|8200|9090)" | awk '{print " " $4}' | sort || echo " (netstat not available)"
|
|
|
|
echo ""
|
|
|
|
# Summary
|
|
echo "================================================================================"
|
|
echo -e "${BLUE}Dependency Check Complete${NC}"
|
|
echo "================================================================================"
|
|
echo ""
|
|
echo "Service Startup Order:"
|
|
echo " 1. PostgreSQL, Redis, Vault, InfluxDB (Infrastructure)"
|
|
echo " 2. Trading Service, Backtesting Service, ML Training Service (Core)"
|
|
echo " 3. API Gateway (Gateway)"
|
|
echo " 4. Prometheus, Grafana (Monitoring - Optional)"
|
|
echo ""
|
|
echo "For troubleshooting, see:"
|
|
echo " - docs/deployment/SERVICE_DEPENDENCIES.md"
|
|
echo " - docs/deployment/DOCKER_TROUBLESHOOTING.md"
|
|
echo ""
|
|
echo "================================================================================"
|