Spaces:
Paused
Paused
File size: 1,966 Bytes
5ee5085 0641d27 5ee5085 0641d27 5ee5085 0641d27 5ee5085 0641d27 5ee5085 0641d27 5ee5085 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #!/bin/bash
# Run ClassLens locally (both backend and frontend)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "๐ Starting ClassLens locally..."
echo ""
# Check for .env file (project root or chatkit/) โ resolve to absolute path
if [ -f "$SCRIPT_DIR/../.env" ]; then
ENV_FILE="$SCRIPT_DIR/../.env"
elif [ -f "$SCRIPT_DIR/.env" ]; then
ENV_FILE="$SCRIPT_DIR/.env"
else
echo "โ ๏ธ No .env file found. Please create one from env.example"
exit 1
fi
echo "๐ Using env file: $ENV_FILE"
# Function to cleanup on exit
cleanup() {
echo ""
echo "๐ Stopping servers..."
pkill -f "uvicorn app.main" 2>/dev/null || true
pkill -f "vite" 2>/dev/null || true
exit 0
}
trap cleanup SIGINT SIGTERM
# Start backend
echo "๐ฆ Starting backend on http://127.0.0.1:8000"
cd backend
if [ ! -d ".venv" ]; then
echo "Creating Python virtual environment..."
python3 -m venv .venv
fi
source .venv/bin/activate
pip install -q -e . > /dev/null 2>&1
# Load environment variables
set -a
source "$ENV_FILE"
set +a
# Start backend in background
uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload > /tmp/classlens-backend.log 2>&1 &
BACKEND_PID=$!
# Wait a bit for backend to start
sleep 2
# Start frontend
echo "๐จ Starting frontend on http://localhost:3003"
cd ../frontend
# Install frontend dependencies if needed
if [ ! -d "node_modules" ]; then
echo "Installing frontend dependencies..."
npm install
fi
# Start frontend
npm run dev > /tmp/classlens-frontend.log 2>&1 &
FRONTEND_PID=$!
echo ""
echo "โ
ClassLens is running!"
echo ""
echo " Backend: http://127.0.0.1:8000"
echo " Frontend: http://localhost:3003"
echo ""
echo " Backend logs: tail -f /tmp/classlens-backend.log"
echo " Frontend logs: tail -f /tmp/classlens-frontend.log"
echo ""
echo "Press Ctrl+C to stop both servers"
echo ""
# Wait for both processes
wait $BACKEND_PID $FRONTEND_PID
|