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:
@@ -2,41 +2,10 @@
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
PROJECT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
|
||||
|
||||
# Defaults
|
||||
OUTDIR=""
|
||||
RELEASE=0
|
||||
CARGO_ARGS=""
|
||||
echo "Building Hero Supervisor..."
|
||||
cd "$PROJECT_DIR"
|
||||
RUSTFLAGS="-A warnings" cargo build --release
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [options]
|
||||
|
||||
Options:
|
||||
--release Use cargo --release
|
||||
--outdir <dir> Output directory (passed to cargo --dist)
|
||||
--cargo-args "..." Extra arguments forwarded to cargo build
|
||||
-h, --help Show this help
|
||||
EOF
|
||||
}
|
||||
|
||||
# Parse args
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--release) RELEASE=1; shift;;
|
||||
--outdir) OUTDIR="$2"; shift 2;;
|
||||
--cargo-args) CARGO_ARGS="$2"; shift 2;;
|
||||
-h|--help) usage; exit 0;;
|
||||
*) echo "❌ Unknown option: $1"; echo; usage; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$SCRIPT_DIR/install.sh"
|
||||
|
||||
set -x
|
||||
cmd=(cargo build)
|
||||
if [[ $RELEASE -eq 1 ]]; then cmd+=(--release); fi
|
||||
if [[ -n "$OUTDIR" ]]; then cmd+=(--dist "$OUTDIR"); fi
|
||||
if [[ -n "$CARGO_ARGS" ]]; then cmd+=($CARGO_ARGS); fi
|
||||
"${cmd[@]}"
|
||||
set +x
|
||||
echo "✅ Hero Supervisor built successfully"
|
||||
@@ -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