start_project.ps1 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # GreaterWMS 后端启动脚本
  2. # 此脚本会启动后端服务
  3. Write-Host "=====================================" -ForegroundColor Cyan
  4. Write-Host " GreaterWMS 后端启动脚本" -ForegroundColor Cyan
  5. Write-Host "=====================================" -ForegroundColor Cyan
  6. Write-Host ""
  7. # 获取脚本所在目录
  8. $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
  9. Set-Location $ScriptDir
  10. # 检查Python是否安装
  11. Write-Host "[1/2] 检查Python环境..." -ForegroundColor Yellow
  12. try {
  13. $pythonVersion = python --version
  14. Write-Host "✓ Python已安装: $pythonVersion" -ForegroundColor Green
  15. } catch {
  16. Write-Host "✗ 未找到Python,请先安装Python" -ForegroundColor Red
  17. pause
  18. exit 1
  19. }
  20. # 启动后端服务
  21. Write-Host "[2/2] 启动后端服务..." -ForegroundColor Yellow
  22. Write-Host "后端服务将运行在: http://0.0.0.0:8008" -ForegroundColor Cyan
  23. # 在新窗口中启动后端
  24. $backendScript = @"
  25. cd '$ScriptDir'
  26. python manage.py makemigrations
  27. python manage.py migrate
  28. Write-Host '后端服务启动中...' -ForegroundColor Green
  29. daphne -b 0.0.0.0 -p 8008 greaterwms.asgi:application
  30. pause
  31. "@
  32. Start-Process powershell -ArgumentList "-NoExit", "-Command", $backendScript
  33. Write-Host ""
  34. Write-Host "=====================================" -ForegroundColor Green
  35. Write-Host "✓ 后端服务启动完成!" -ForegroundColor Green
  36. Write-Host "=====================================" -ForegroundColor Green
  37. Write-Host ""
  38. Write-Host "后端服务: http://localhost:8008" -ForegroundColor Cyan
  39. Write-Host ""
  40. Write-Host "服务窗口已打开,请勿关闭。" -ForegroundColor Yellow
  41. Write-Host "按任意键退出此窗口(服务将继续运行)..." -ForegroundColor Gray
  42. pause