Files
Infstar/scripts/start-test-server.ps1
T

29 lines
766 B
PowerShell

param(
[int] $MemoryMinGb = 2,
[int] $MemoryMaxGb = 4
)
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
$runDirectory = Join-Path $projectRoot "run"
$serverJar = Join-Path $runDirectory "infstar.jar"
if (-not (Test-Path -LiteralPath $serverJar -PathType Leaf)) {
throw "未找到 $serverJar。请先运行 prepare-test-server.ps1。"
}
$java = Get-Command java -ErrorAction SilentlyContinue
if ($null -eq $java) {
throw "未找到 Java。Infstar 26.2 需要 Java 25。"
}
Push-Location $runDirectory
try {
& $java.Source "-Xms${MemoryMinGb}G" "-Xmx${MemoryMaxGb}G" "-jar" $serverJar "--nogui"
if ($LASTEXITCODE -ne 0) {
throw "测试服务器退出,代码:$LASTEXITCODE"
}
}
finally {
Pop-Location
}