#!/bin/bash set -e echo "🚀 Starting Orbital Simulator Interfaces..." # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Function to check if a command exists command_exists() { command -v "$1" &> /dev/null } # Check prerequisites echo -e "${BLUE}Checking prerequisites...${NC}" if ! command_exists cargo; then echo -e "${RED}❌ Rust/Cargo not found. Please install Rust first.${NC}" exit 1 fi if ! command_exists node; then echo -e "${RED}❌ Node.js not found. Please install Node.js first.${NC}" exit 1 fi if ! command_exists python3; then echo -e "${RED}❌ Python 3 not found. Please install Python 3 first.${NC}" exit 1 fi echo -e "${GREEN}✅ Prerequisites check passed${NC}" # Build Rust project echo -e "${BLUE}Building Rust project...${NC}" cargo build --release # Install web dependencies if needed if [ ! -d "web/node_modules" ]; then echo -e "${BLUE}Installing web dependencies...${NC}" cd web npm install cd .. fi # Install Python dependencies if needed if [ ! -f ".venv/bin/python" ]; then echo -e "${BLUE}Setting up Python virtual environment...${NC}" python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt else source .venv/bin/activate fi # Function to kill background processes on exit cleanup() { echo -e "\n${YELLOW}Shutting down services...${NC}" kill $(jobs -p) 2>/dev/null || true exit 0 } trap cleanup SIGINT SIGTERM # Start API server echo -e "${BLUE}Starting API server...${NC}" cargo run --release --bin api_server & API_PID=$! # Wait for API server to start sleep 3 # Check if API server is running if curl -s http://localhost:3000/api/configs > /dev/null; then echo -e "${GREEN}✅ API server running on http://localhost:3000${NC}" else echo -e "${RED}❌ API server failed to start${NC}" kill $API_PID 2>/dev/null || true exit 1 fi # Start web interface echo -e "${BLUE}Starting web interface...${NC}" cd web npm run dev & WEB_PID=$! cd .. # Wait for web interface to start sleep 5 echo -e "${GREEN}✅ Web interface running on http://localhost:5173${NC}" # Start desktop GUI if Tauri is available if command_exists cargo-tauri; then echo -e "${BLUE}Starting desktop GUI...${NC}" cargo tauri dev & GUI_PID=$! echo -e "${GREEN}✅ Desktop GUI launching...${NC}" else echo -e "${YELLOW}⚠️ Tauri not installed. Skipping desktop GUI.${NC}" echo -e "${YELLOW} Install with: cargo install tauri-cli${NC}" fi echo -e "\n${GREEN}🎉 All interfaces started successfully!${NC}" echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${GREEN}📊 API Server: ${NC}http://localhost:3000" echo -e "${GREEN}🌐 Web Interface: ${NC}http://localhost:5173" if command_exists cargo-tauri; then echo -e "${GREEN}🖥️ Desktop GUI: ${NC}Opening in new window" fi echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${YELLOW}Press Ctrl+C to stop all services${NC}" # Keep script running wait