#!/bin/bash # Hero Supervisor Development Runner # Runs both the supervisor backend and admin UI frontend set -e # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${BLUE}║ Starting Hero Supervisor Development Environment ║${NC}" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}" # Function to cleanup background processes on exit cleanup() { echo -e "\n${YELLOW}Shutting down...${NC}" kill $(jobs -p) 2>/dev/null || true exit 0 } trap cleanup SIGINT SIGTERM # Check if Redis is running if ! pgrep -x "redis-server" > /dev/null; then echo -e "${YELLOW}⚠️ Redis not detected. Starting Redis...${NC}" redis-server --daemonize yes sleep 1 fi # Start the supervisor with bootstrap admin key echo -e "${GREEN}🚀 Starting Hero Supervisor...${NC}" cargo run --bin supervisor -- \ --bootstrap-admin-key "admin" \ --redis-url "redis://localhost:6379" \ --port 3030 \ --bind-address "127.0.0.1" & SUPERVISOR_PID=$! # Wait for supervisor to start echo -e "${BLUE}⏳ Waiting for supervisor to initialize...${NC}" sleep 3 # Start the admin UI echo -e "${GREEN}🎨 Starting Admin UI...${NC}" cd clients/admin-ui trunk serve --port 8080 & ADMIN_UI_PID=$! # Wait a bit for trunk to start sleep 2 echo -e "\n${GREEN}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}║ ✅ Development Environment Ready! ║${NC}" echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}" echo -e "${BLUE} 📡 Supervisor API:${NC} http://127.0.0.1:3030" echo -e "${BLUE} 🎨 Admin UI:${NC} http://127.0.0.1:8080" echo -e "${BLUE} 🔗 Redis:${NC} redis://localhost:6379" echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}" echo -e "\n${YELLOW}💡 Check the supervisor output above for your admin API key!${NC}" echo -e "${YELLOW} Use it to login to the Admin UI at http://127.0.0.1:8080${NC}\n" echo -e "${YELLOW}Press Ctrl+C to stop all services${NC}\n" # Wait for both processes wait