Files
GUI-Agent/SystemTest-Controller/start_controller.ps1
T

54 lines
1.3 KiB
PowerShell

param(
[string]$HostName,
[int]$Port = 0
)
$ErrorActionPreference = "Stop"
Set-Location -LiteralPath $PSScriptRoot
if ($HostName) {
$env:CONTROLLER_HOST = $HostName
}
if ($Port -gt 0) {
$env:CONTROLLER_PORT = [string]$Port
if (-not $env:CONTROLLER_PUBLIC_BASE_URL) {
$env:CONTROLLER_PUBLIC_BASE_URL = "http://127.0.0.1:$Port"
}
}
$pythonExe = $null
$pythonArgs = @()
if ($env:PYTHON_EXE -and (Test-Path -LiteralPath $env:PYTHON_EXE)) {
$pythonExe = $env:PYTHON_EXE
}
if (-not $pythonExe) {
$bundledPython = Join-Path $env:USERPROFILE '.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe'
if (Test-Path -LiteralPath $bundledPython) {
$pythonExe = $bundledPython
}
}
if (-not $pythonExe) {
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
if ($pythonCommand) {
$pythonExe = $pythonCommand.Source
}
}
if (-not $pythonExe) {
$pythonCommand = Get-Command py -ErrorAction SilentlyContinue
if ($pythonCommand) {
$pythonExe = $pythonCommand.Source
$pythonArgs = @('-3')
}
}
if (-not $pythonExe) {
throw "Python 3 was not found. Install Python 3, set PYTHON_EXE, or add Python to PATH."
}
& $pythonExe @pythonArgs -m app
exit $LASTEXITCODE