process-aware-ai / run_app.sh
borndeveloper's picture
Deploy Process Aware AI Dashboard without binaries
b4a2e7f
Raw
History Blame Contribute Delete
1.62 kB
#!/bin/bash
# Get the directory where this script lives
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Cleaning up ports 8000 and 3000..."
lsof -t -i:8000 | xargs -r kill -9 2>/dev/null
lsof -t -i:3000 | xargs -r kill -9 2>/dev/null
sleep 1
# Check venv exists
if [ ! -f "$SCRIPT_DIR/venv/bin/uvicorn" ]; then
echo "ERROR: venv not found or uvicorn not installed."
echo "Creating venv and installing dependencies..."
python3 -m venv "$SCRIPT_DIR/venv"
"$SCRIPT_DIR/venv/bin/pip" install -r "$SCRIPT_DIR/backend/requirements.txt"
fi
# Start Backend (must run from backend/ dir for relative imports)
echo "Starting Backend..."
cd "$SCRIPT_DIR/backend"
"$SCRIPT_DIR/venv/bin/uvicorn" app.main:app --host 0.0.0.0 --port 8000 > "$SCRIPT_DIR/backend/backend.log" 2>&1 &
BACKEND_PID=$!
# Wait a moment for backend to start
sleep 2
# Check if backend started successfully
if ! kill -0 $BACKEND_PID 2>/dev/null; then
echo "ERROR: Backend failed to start! Check backend/backend.log"
cat "$SCRIPT_DIR/backend/backend.log"
exit 1
fi
# Start Frontend
echo "Starting Frontend..."
cd "$SCRIPT_DIR/frontend"
npm run dev > "$SCRIPT_DIR/frontend/frontend.log" 2>&1 &
FRONTEND_PID=$!
echo "------------------------------------------------"
echo "PROCESS AWARE AI - DASHBOARD"
echo "------------------------------------------------"
echo "Frontend: http://localhost:3000"
echo "Backend: http://localhost:8000"
echo "Logs: backend/backend.log and frontend/frontend.log"
echo "Press Ctrl+C to stop everything."
trap "kill $BACKEND_PID $FRONTEND_PID 2>/dev/null; exit" SIGINT SIGTERM
wait