assistant/scripts/read-port.ps1

11 lines
350 B
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.

# 从 .env 读取 API_PORT,默认 8788
param([string]$Root = (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)))
$port = 8788
$envFile = Join-Path $Root ".env"
if (Test-Path $envFile) {
Get-Content $envFile | ForEach-Object {
if ($_ -match '^\s*API_PORT\s*=\s*(\d+)') { $port = [int]$Matches[1] }
}
}
Write-Output $port