Spaces:
Running
Running
| # Run backend + frontend build watcher so frontend auto-rebuilds on change (no manual npm run build). | |
| set -e | |
| cd "$(dirname "$0")" | |
| if [ ! -d "venv" ]; then | |
| echo "β venv not found. Run: bash setup.sh" | |
| exit 1 | |
| fi | |
| source venv/bin/activate | |
| # Build frontend once, then start watcher in background | |
| echo "π¦ Building frontend once..." | |
| (cd frontend && npm run build) | |
| echo "π Starting frontend build watcher (rebuilds on file change)..." | |
| (cd frontend && npm run build:watch) & | |
| WATCHER_PID=$! | |
| trap "kill $WATCHER_PID 2>/dev/null" EXIT | |
| # Wait for dist/assets so Python doesn't start while watcher cleared the dir | |
| echo "β³ Waiting for frontend build to be ready..." | |
| i=0 | |
| while [ $i -lt 30 ]; do | |
| if [ -d "frontend/dist/assets" ] && [ -n "$(ls frontend/dist/assets 2>/dev/null)" ]; then | |
| break | |
| fi | |
| sleep 1 | |
| i=$((i + 1)) | |
| done | |
| if [ ! -d "frontend/dist/assets" ] || [ -z "$(ls frontend/dist/assets 2>/dev/null)" ]; then | |
| echo "β frontend/dist/assets not ready after 30s. Check frontend build." | |
| exit 1 | |
| fi | |
| echo "π Starting backend at http://localhost:4000" | |
| echo " Edit frontend files β auto-rebuild β refresh browser" | |
| echo "" | |
| python main.py | |