Simplify build.sh and update run.sh for self-contained execution
- Simplified build.sh to just build in release mode with warning suppression - Updated run.sh to build first, then start supervisor and admin UI together - Run script now starts both supervisor API and admin UI in background - Added proper cleanup handler for graceful shutdown - Removed admin UI compilation errors by fixing JsValue handling - Added list_jobs method to WASM client for admin UI compatibility
This commit is contained in:
@@ -1,70 +1,64 @@
|
||||
#!/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
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
PROJECT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
|
||||
|
||||
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║ Starting Hero Supervisor Development Environment ║${NC}"
|
||||
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
|
||||
# Build first
|
||||
"$SCRIPT_DIR/build.sh"
|
||||
|
||||
# Function to cleanup background processes on exit
|
||||
# Configuration
|
||||
REDIS_URL="${REDIS_URL:-redis://localhost:6379}"
|
||||
PORT="${PORT:-3030}"
|
||||
BIND_ADDRESS="${BIND_ADDRESS:-127.0.0.1}"
|
||||
BOOTSTRAP_ADMIN_KEY="${BOOTSTRAP_ADMIN_KEY:-admin}"
|
||||
ADMIN_UI_PORT="${ADMIN_UI_PORT:-8080}"
|
||||
LOG_LEVEL="${LOG_LEVEL:-info}"
|
||||
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
echo -e "\n${YELLOW}Shutting down...${NC}"
|
||||
echo "Shutting down..."
|
||||
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
|
||||
echo "Starting Hero Supervisor..."
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
# 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" &
|
||||
# Start supervisor in background
|
||||
RUST_LOG="$LOG_LEVEL" RUST_LOG_STYLE=never \
|
||||
target/release/supervisor \
|
||||
--bootstrap-admin-key "$BOOTSTRAP_ADMIN_KEY" \
|
||||
--redis-url "$REDIS_URL" \
|
||||
--port "$PORT" \
|
||||
--bind-address "$BIND_ADDRESS" &
|
||||
|
||||
SUPERVISOR_PID=$!
|
||||
|
||||
# Wait for supervisor to start
|
||||
echo -e "${BLUE}⏳ Waiting for supervisor to initialize...${NC}"
|
||||
sleep 3
|
||||
sleep 2
|
||||
|
||||
# Start the admin UI
|
||||
echo -e "${GREEN}🎨 Starting Admin UI...${NC}"
|
||||
cd clients/admin-ui
|
||||
trunk serve --port 8080 &
|
||||
# Check if supervisor is running
|
||||
if ! ps -p $SUPERVISOR_PID > /dev/null 2>&1; then
|
||||
echo "Failed to start supervisor"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start admin UI
|
||||
echo "Starting Admin UI on port $ADMIN_UI_PORT..."
|
||||
cd "$PROJECT_DIR/clients/admin-ui"
|
||||
trunk serve --port "$ADMIN_UI_PORT" &
|
||||
|
||||
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"
|
||||
echo ""
|
||||
echo "✅ Hero Supervisor system started"
|
||||
echo " 📡 Supervisor API: http://$BIND_ADDRESS:$PORT"
|
||||
echo " 🎨 Admin UI: http://127.0.0.1:$ADMIN_UI_PORT"
|
||||
echo ""
|
||||
echo "Press Ctrl+C to stop all services"
|
||||
|
||||
# Wait for both processes
|
||||
wait
|
||||
Reference in New Issue
Block a user