File size: 1,907 Bytes
d3f86d8 |
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 |
#!/bin/bash
# Script to run both frontend and backend in development mode
echo "π Starting HFStudio Development Environment..."
echo ""
# Check if tmux is installed
if command -v tmux &> /dev/null; then
# Create a new tmux session
tmux new-session -d -s hfstudio
# Split window horizontally
tmux split-window -h
# Run backend in left pane
tmux send-keys -t hfstudio:0.0 'python -m hfstudio.cli --dev' C-m
# Run frontend in right pane
tmux send-keys -t hfstudio:0.1 'cd frontend && npm install && npm run dev' C-m
# Attach to session
tmux attach-session -t hfstudio
else
# Run without tmux
echo "Running without tmux (install tmux for better experience)"
echo ""
echo "Starting Backend..."
python -m hfstudio.cli --dev &
BACKEND_PID=$!
echo "Starting Frontend..."
cd frontend
npm install
npm run dev &
FRONTEND_PID=$!
echo ""
echo "Services running:"
echo " Frontend: http://localhost:11111"
echo " Backend: http://localhost:7860"
echo " API Docs: http://localhost:7860/docs"
echo ""
# Wait for frontend to be ready then open browser
echo "Waiting for services to start..."
sleep 3
# Open browser based on OS
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
open http://localhost:11111
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
xdg-open http://localhost:11111 2>/dev/null || sensible-browser http://localhost:11111
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "win32" ]]; then
# Windows
start http://localhost:11111
fi
echo "Browser opened at http://localhost:11111"
echo ""
echo "Press Ctrl+C to stop all services"
# Wait and handle shutdown
trap "kill $BACKEND_PID $FRONTEND_PID" EXIT
wait
fi |