| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- # PowerShell 脚本:启动拖轮项目的所有服务
- Write-Host "==========================================" -ForegroundColor Green
- Write-Host " 拖轮项目多服务启动脚本" -ForegroundColor Green
- Write-Host "==========================================" -ForegroundColor Green
- # 检查Java是否安装
- Write-Host "`n检查Java环境..." -ForegroundColor Yellow
- try {
- $javaVersion = java -version 2>&1
- Write-Host "Java 版本: $javaVersion" -ForegroundColor Green
- } catch {
- Write-Host "错误: 未找到Java环境,请先安装Java" -ForegroundColor Red
- exit 1
- }
- # 检查Node.js是否安装
- Write-Host "`n检查Node.js环境..." -ForegroundColor Yellow
- try {
- $nodeVersion = node --version
- $npmVersion = npm --version
- Write-Host "Node.js 版本: $nodeVersion" -ForegroundColor Green
- Write-Host "NPM 版本: $npmVersion" -ForegroundColor Green
- } catch {
- Write-Host "错误: 未找到Node.js环境,请先安装Node.js" -ForegroundColor Red
- exit 1
- }
- # 启动认证服务
- Write-Host "`n1. 启动认证服务 (端口 8083)..." -ForegroundColor Cyan
- Set-Location -Path "$PSScriptRoot\com.lianda.auth"
- # 检查Maven是否可用
- $mavenAvailable = Get-Command mvn -ErrorAction SilentlyContinue
- if ($mavenAvailable) {
- Write-Host "使用Maven启动认证服务..." -ForegroundColor Yellow
- Start-Process -FilePath "cmd.exe" -ArgumentList "/k", "mvn spring-boot:run"
- } else {
- Write-Host "Maven不可用,请先安装Maven" -ForegroundColor Red
- exit 1
- }
- # 启动后端服务
- Write-Host "`n2. 启动Java后端服务 (端口 8080)..." -ForegroundColor Cyan
- Set-Location -Path "$PSScriptRoot\JavaBackend"
- if ($mavenAvailable) {
- Write-Host "使用Maven启动后端服务..." -ForegroundColor Yellow
- Start-Sleep -Seconds 3
- Start-Process -FilePath "cmd.exe" -ArgumentList "/k", "mvn spring-boot:run"
- } else {
- Write-Host "Maven不可用,尝试使用jar包启动..." -ForegroundColor Yellow
- # 尝试打包并运行
- $buildResult = mvn clean package -DskipTests
- if ($buildResult -ne $null) {
- # 查找生成的jar文件并启动
- $jarFile = Get-ChildItem -Path ".\target" -Filter "*.jar" | Select-Object -First 1
- if ($jarFile) {
- Write-Host "找到JAR文件: $($jarFile.Name)" -ForegroundColor Green
- Start-Sleep -Seconds 3
- Start-Process -FilePath "cmd.exe" -ArgumentList "/k", "java -jar $($jarFile.FullName)"
- } else {
- Write-Host "错误: 未找到可执行的JAR文件" -ForegroundColor Red
- }
- }
- }
- # 启动前端服务
- Write-Host "`n3. 启动Vue前端服务 (端口 8082)..." -ForegroundColor Cyan
- Set-Location -Path "$PSScriptRoot\vue-frontend"
- # 安装依赖(如果需要)
- if (!(Test-Path -Path "node_modules")) {
- Write-Host "安装前端依赖..." -ForegroundColor Yellow
- npm install
- }
- # 启动前端开发服务器
- Start-Sleep -Seconds 3
- Start-Process -FilePath "cmd.exe" -ArgumentList "/k", "npm run serve"
- # 启动数据同步服务
- Write-Host "`n4. 启动FlinkDataSync数据同步服务..." -ForegroundColor Cyan
- Set-Location -Path "$PSScriptRoot\FlinkDataSync"
- if ($mavenAvailable) {
- Write-Host "构建FlinkDataSync项目..." -ForegroundColor Yellow
- $buildResult = mvn clean package -DskipTests
- if ($buildResult -ne $null) {
- Write-Host "构建成功,启动数据同步服务..." -ForegroundColor Green
- Start-Sleep -Seconds 3
- Start-Process -FilePath "cmd.exe" -ArgumentList "/k", "java -cp target\flink-data-sync-1.0-SNAPSHOT.jar com.lianda.flink.sync.MySqlCdcSync"
- } else {
- Write-Host "错误: 构建FlinkDataSync失败" -ForegroundColor Red
- }
- } else {
- Write-Host "Maven不可用,无法构建FlinkDataSync" -ForegroundColor Red
- }
- Write-Host "`n==========================================" -ForegroundColor Green
- Write-Host "服务启动完成!" -ForegroundColor Green
- Write-Host "- 认证服务: http://localhost:8083/auth" -ForegroundColor Green
- Write-Host "- 后端服务: http://localhost:8080/api" -ForegroundColor Green
- Write-Host "- 前端服务: http://localhost:8082/" -ForegroundColor Green
- Write-Host "- 数据同步服务: 运行中(后台)" -ForegroundColor Green
- Write-Host "==========================================" -ForegroundColor Green
- Write-Host "`n提示: 关闭终端窗口将停止相应的服务" -ForegroundColor Yellow
|