Twilioapp/start-servers.ps1

69 lines
2.7 KiB
PowerShell
Raw Permalink Normal View History

2025-06-29 01:33:41 +08:00
# Twilio视频通话服务启动脚本
Write-Host "🚀 启动 Twilio 视频通话服务..." -ForegroundColor Green
# 检查Node.js是否安装
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Host "❌ 错误: 未找到 Node.js请先安装 Node.js" -ForegroundColor Red
exit 1
}
# 检查npm是否安装
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
Write-Host "❌ 错误: 未找到 npm请先安装 npm" -ForegroundColor Red
exit 1
}
Write-Host "📦 检查并安装依赖..." -ForegroundColor Yellow
# 安装前端依赖
Write-Host "安装前端依赖..." -ForegroundColor Cyan
if (-not (Test-Path "node_modules")) {
npm install
}
# 安装后端依赖
Write-Host "安装后端依赖..." -ForegroundColor Cyan
if (-not (Test-Path "server/node_modules")) {
Set-Location server
npm install
Set-Location ..
}
Write-Host "🎬 启动服务器..." -ForegroundColor Green
# 启动后端Token服务器
Write-Host "启动 Twilio Token 服务器 (端口 3001)..." -ForegroundColor Cyan
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd server; npm start" -WindowStyle Normal
# 等待2秒让后端启动
Start-Sleep -Seconds 2
# 启动前端开发服务器
Write-Host "启动前端开发服务器 (端口 5175)..." -ForegroundColor Cyan
Start-Process powershell -ArgumentList "-NoExit", "-Command", "npm run dev" -WindowStyle Normal
# 等待3秒让服务器启动
Start-Sleep -Seconds 3
Write-Host ""
Write-Host "✅ 服务启动完成!" -ForegroundColor Green
Write-Host ""
Write-Host "📋 访问地址:" -ForegroundColor Yellow
Write-Host " 前端应用: http://localhost:5175" -ForegroundColor White
Write-Host " 视频测试: http://localhost:5175/video-test" -ForegroundColor White
Write-Host " 后端API: http://localhost:3001" -ForegroundColor White
Write-Host " 健康检查: http://localhost:3001/health" -ForegroundColor White
Write-Host ""
Write-Host "🧪 测试步骤:" -ForegroundColor Yellow
Write-Host " 1. 访问 http://localhost:5175/video-test" -ForegroundColor White
Write-Host " 2. 填写房间名称和用户身份" -ForegroundColor White
Write-Host " 3. 点击'加入通话'按钮" -ForegroundColor White
Write-Host " 4. 在新标签页中重复步骤1-3测试多人通话" -ForegroundColor White
Write-Host ""
Write-Host "⚠️ 注意事项:" -ForegroundColor Red
Write-Host " - 确保已配置正确的 Twilio 凭证" -ForegroundColor White
Write-Host " - 允许浏览器访问摄像头和麦克风" -ForegroundColor White
Write-Host " - 使用 HTTPS 或 localhost 以获得最佳体验" -ForegroundColor White
Write-Host ""
Write-Host "按任意键退出..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")