#!/bin/bash echo "🔄 Restarting PureStream WebApp..." # Function to kill process on port kill_port() { PORT=$1 if lsof -i:$PORT -t >/dev/null; then PID=$(lsof -ti:$PORT) echo "Killing process on port $PORT (PID: $PID)..." kill -9 $PID else echo "Port $PORT is free." fi } # 1. Stop existing processes echo "🛑 Stopping services..." kill_port 8000 # Backend kill_port 8002 # Frontend (Target) kill_port 8003 # Frontend (Alt) kill_port 5173 # Frontend (Default) # 2. Start Backend echo "🚀 Starting Backend (Port 8000)..." cd backend # Check if venv exists matching user env, else use python3 PYTHON_CMD="python3" # Start uvicorn in background nohup $PYTHON_CMD -m uvicorn main:app --reload --host 0.0.0.0 --port 8000 > ../backend.log 2>&1 & BACKEND_PID=$! echo "Backend started with PID $BACKEND_PID" cd .. # 3. Start Frontend echo "🎨 Starting Frontend (Port 8002)..." cd frontend # Start vite in background nohup npm run dev -- --port 8002 --host > ../frontend.log 2>&1 & FRONTEND_PID=$! echo "Frontend started with PID $FRONTEND_PID" cd .. echo "✅ App restarted successfully!" echo "--------------------------------" echo "Backend: http://localhost:8000" echo "Frontend: http://localhost:8002" echo "--------------------------------" echo "Logs are being written to backend.log and frontend.log"