start.ps1 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Quick Start Script for Spring Cloud Log Demo System (PowerShell)
  2. Write-Host "================================" -ForegroundColor Cyan
  3. Write-Host "Spring Cloud Log Demo - Quick Start" -ForegroundColor Cyan
  4. Write-Host "================================" -ForegroundColor Cyan
  5. Write-Host ""
  6. # Check prerequisites
  7. Write-Host "[1/5] Checking prerequisites..." -ForegroundColor Yellow
  8. $errorCount = 0
  9. if (-not (Get-Command java -ErrorAction SilentlyContinue)) {
  10. Write-Host "ERROR: Java is not installed" -ForegroundColor Red
  11. $errorCount++
  12. } else {
  13. $javaVersion = java -version 2>&1 | Select-Object -First 1
  14. Write-Host "✓ Java: $javaVersion" -ForegroundColor Green
  15. }
  16. if (-not (Get-Command mvn -ErrorAction SilentlyContinue)) {
  17. Write-Host "ERROR: Maven is not installed" -ForegroundColor Red
  18. $errorCount++
  19. } else {
  20. $mvnVersion = mvn -v 2>&1 | Select-Object -First 1
  21. Write-Host "✓ Maven: $mvnVersion" -ForegroundColor Green
  22. }
  23. if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
  24. Write-Host "ERROR: Node.js is not installed" -ForegroundColor Red
  25. $errorCount++
  26. } else {
  27. $nodeVersion = node -v
  28. Write-Host "✓ Node: $nodeVersion" -ForegroundColor Green
  29. }
  30. if ($errorCount -gt 0) {
  31. Write-Host "Please install missing prerequisites" -ForegroundColor Red
  32. exit 1
  33. }
  34. Write-Host ""
  35. # Build backend
  36. Write-Host "[2/5] Building backend services..." -ForegroundColor Yellow
  37. mvn clean install -DskipTests | Out-Null
  38. Write-Host "✓ Backend build completed" -ForegroundColor Green
  39. Write-Host ""
  40. # Start services
  41. Write-Host "[3/5] Starting backend services..." -ForegroundColor Yellow
  42. Write-Host " - Gateway (port 8080)" -ForegroundColor White
  43. Push-Location shop-recycle-gateway
  44. Start-Process mvn -ArgumentList "spring-boot:run" -WindowStyle Minimized
  45. Write-Host " Started" -ForegroundColor Green
  46. Pop-Location
  47. Start-Sleep -Seconds 3
  48. Write-Host " - Order Service (port 8081)" -ForegroundColor White
  49. Push-Location shop-recycle-order-service
  50. Start-Process mvn -ArgumentList "spring-boot:run" -WindowStyle Minimized
  51. Write-Host " Started" -ForegroundColor Green
  52. Pop-Location
  53. Write-Host " - Payment Service (port 8082)" -ForegroundColor White
  54. Push-Location shop-recycle-payment-service
  55. Start-Process mvn -ArgumentList "spring-boot:run" -WindowStyle Minimized
  56. Write-Host " Started" -ForegroundColor Green
  57. Pop-Location
  58. Start-Sleep -Seconds 5
  59. Write-Host "✓ All backend services started" -ForegroundColor Green
  60. Write-Host ""
  61. # Frontend setup
  62. Write-Host "[4/5] Installing frontend dependencies..." -ForegroundColor Yellow
  63. Push-Location shop-recycle-web
  64. npm install | Out-Null
  65. Write-Host "✓ Frontend dependencies installed" -ForegroundColor Green
  66. Pop-Location
  67. Write-Host ""
  68. Write-Host "[5/5] Starting frontend development server..." -ForegroundColor Yellow
  69. Push-Location shop-recycle-web
  70. Write-Host "Frontend will open in a new terminal..." -ForegroundColor Cyan
  71. Start-Process cmd -ArgumentList "/c npm run dev"
  72. Pop-Location
  73. Write-Host ""
  74. Write-Host "================================" -ForegroundColor Green
  75. Write-Host "✓ All services are running!" -ForegroundColor Green
  76. Write-Host "================================" -ForegroundColor Green
  77. Write-Host ""
  78. Write-Host "🌐 Frontend: http://localhost:5173" -ForegroundColor Cyan
  79. Write-Host "🔌 API Gateway: http://localhost:8080" -ForegroundColor Cyan
  80. Write-Host "📦 Order Service: http://localhost:8081/api" -ForegroundColor Cyan
  81. Write-Host "💰 Payment Service: http://localhost:8082/api" -ForegroundColor Cyan
  82. Write-Host ""
  83. Write-Host "📋 Check logs in the terminal windows that opened" -ForegroundColor Yellow
  84. Write-Host ""
  85. Write-Host "💡 Tips:" -ForegroundColor Yellow
  86. Write-Host " 1. Open http://localhost:5173 in your browser" -ForegroundColor White
  87. Write-Host " 2. Create an order and complete payment" -ForegroundColor White
  88. Write-Host " 3. Watch the structured JSON logs in backend terminals" -ForegroundColor White
  89. Write-Host " 4. Observe traceId, uri_group, event_class, duration fields" -ForegroundColor White
  90. Write-Host ""