start.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # Quick Start Script for Spring Cloud Log Demo System
  3. set -e
  4. echo "================================"
  5. echo "Spring Cloud Log Demo - Quick Start"
  6. echo "================================"
  7. echo ""
  8. # Check prerequisites
  9. echo "[1/5] Checking prerequisites..."
  10. if ! command -v java &> /dev/null; then
  11. echo "ERROR: Java is not installed"
  12. exit 1
  13. fi
  14. if ! command -v mvn &> /dev/null; then
  15. echo "ERROR: Maven is not installed"
  16. exit 1
  17. fi
  18. if ! command -v node &> /dev/null; then
  19. echo "ERROR: Node.js is not installed"
  20. exit 1
  21. fi
  22. echo "✓ Java version: $(java -version 2>&1 | head -1)"
  23. echo "✓ Maven version: $(mvn -v | head -1)"
  24. echo "✓ Node version: $(node -v)"
  25. echo ""
  26. # Build backend
  27. echo "[2/5] Building backend services..."
  28. mvn clean install -DskipTests > /dev/null
  29. echo "✓ Backend build completed"
  30. echo ""
  31. # Start services in background
  32. echo "[3/5] Starting backend services..."
  33. echo " - Gateway (port 8080)"
  34. cd shop-recycle-gateway
  35. mvn spring-boot:run > /tmp/gateway.log 2>&1 &
  36. GATEWAY_PID=$!
  37. echo " Started with PID $GATEWAY_PID"
  38. sleep 3
  39. echo " - Order Service (port 8081)"
  40. cd ../shop-recycle-order-service
  41. mvn spring-boot:run > /tmp/order.log 2>&1 &
  42. ORDER_PID=$!
  43. echo " Started with PID $ORDER_PID"
  44. echo " - Payment Service (port 8082)"
  45. cd ../shop-recycle-payment-service
  46. mvn spring-boot:run > /tmp/payment.log 2>&1 &
  47. PAYMENT_PID=$!
  48. echo " Started with PID $PAYMENT_PID"
  49. sleep 5
  50. echo "✓ All backend services started"
  51. echo ""
  52. # Start frontend
  53. echo "[4/5] Installing frontend dependencies..."
  54. cd ../shop-recycle-web
  55. npm install > /dev/null 2>&1
  56. echo "✓ Frontend dependencies installed"
  57. echo ""
  58. echo "[5/5] Starting frontend development server..."
  59. npm run dev &
  60. FRONTEND_PID=$!
  61. echo "✓ Frontend started with PID $FRONTEND_PID"
  62. echo ""
  63. echo "================================"
  64. echo "✓ All services are running!"
  65. echo "================================"
  66. echo ""
  67. echo "🌐 Frontend: http://localhost:5173"
  68. echo "🔌 API Gateway: http://localhost:8080"
  69. echo "📦 Order Service: http://localhost:8081/api"
  70. echo "💰 Payment Service: http://localhost:8082/api"
  71. echo ""
  72. echo "📋 Backend logs:"
  73. echo " - Gateway: tail -f /tmp/gateway.log"
  74. echo " - Order: tail -f /tmp/order.log"
  75. echo " - Payment: tail -f /tmp/payment.log"
  76. echo ""
  77. echo "🛑 To stop all services, run: pkill -f maven; kill $FRONTEND_PID"
  78. echo ""