cmvr-wms/ruoyi-project/scripts/Start-Local.ps1

16 lines
1.4 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

param([int]$Port=8091)
$ErrorActionPreference='Stop'
$taskProjectRoot=(Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
$taskPmTemp=Join-Path $taskProjectRoot '.codex-tmp'
# 仅启动本模块的本地验证进程;不终止用户 IDE 调试服务或更改现有前端代理。
if(Get-NetTCPConnection -State Listen -LocalPort $Port -ErrorAction SilentlyContinue) { throw "端口 $Port 已在使用,请选择其它本地端口。" }
if(!$env:JAVA_HOME) { throw '请设置 JAVA_HOME 为 Java 17 或更新版本。' }
$taskJava=Join-Path $env:JAVA_HOME 'bin/java.exe'
if(!(Test-Path -LiteralPath $taskJava)) { throw '请设置 JAVA_HOME 为 Java 17 或更新版本。' }
New-Item -ItemType Directory -Path $taskPmTemp -Force | Out-Null
$env:RUOYI_PROFILE=Join-Path $taskPmTemp 'pm-uploads'
$env:RUOYI_LOG_PATH=Join-Path $taskPmTemp 'pm-logs'
$taskArgs=@('-Dfile.encoding=UTF-8','-jar','ruoyi-admin/target/cmvr-wms.jar',"--server.port=$Port",'--spring.quartz.auto-startup=false','--spring.devtools.restart.enabled=false')
$taskProcess=Start-Process -FilePath $taskJava -ArgumentList $taskArgs -WorkingDirectory $taskProjectRoot -WindowStyle Hidden -RedirectStandardOutput (Join-Path $taskPmTemp 'pm-backend.out.log') -RedirectStandardError (Join-Path $taskPmTemp 'pm-backend.err.log') -PassThru
Write-Output "项目协作后端:http://127.0.0.1:$Port;PID=$($taskProcess.Id)。已有 IDE 服务保持运行。"