dev.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Development script for llama.cpp webui
  3. #
  4. # This script starts the webui development servers (Storybook and Vite).
  5. # Note: You need to start llama-server separately.
  6. #
  7. # Usage:
  8. # bash scripts/dev.sh
  9. # npm run dev
  10. cd ../../../
  11. # Check and install git hooks if missing
  12. check_and_install_hooks() {
  13. local hooks_missing=false
  14. # Check for required hooks
  15. if [ ! -f ".git/hooks/pre-commit" ] || [ ! -f ".git/hooks/pre-push" ] || [ ! -f ".git/hooks/post-push" ]; then
  16. hooks_missing=true
  17. fi
  18. if [ "$hooks_missing" = true ]; then
  19. echo "🔧 Git hooks missing, installing them..."
  20. cd tools/server/webui
  21. if bash scripts/install-git-hooks.sh; then
  22. echo "✅ Git hooks installed successfully"
  23. else
  24. echo "⚠️ Failed to install git hooks, continuing anyway..."
  25. fi
  26. cd ../../../
  27. else
  28. echo "✅ Git hooks already installed"
  29. fi
  30. }
  31. # Install git hooks if needed
  32. check_and_install_hooks
  33. # Cleanup function
  34. cleanup() {
  35. echo "🧹 Cleaning up..."
  36. exit
  37. }
  38. # Set up signal handlers
  39. trap cleanup SIGINT SIGTERM
  40. echo "🚀 Starting development servers..."
  41. echo "📝 Note: Make sure to start llama-server separately if needed"
  42. cd tools/server/webui
  43. # Use --insecure-http-parser to handle malformed HTTP responses from llama-server
  44. # (some responses have both Content-Length and Transfer-Encoding headers)
  45. storybook dev -p 6006 --ci & NODE_OPTIONS="--insecure-http-parser" vite dev --host 0.0.0.0 &
  46. # Wait for all background processes
  47. wait