35 lines
915 B
PowerShell
35 lines
915 B
PowerShell
param([switch]$NoOpen)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$url = "http://127.0.0.1:8765/tools/recipe-tree-editor/"
|
|
$statusUrl = "http://127.0.0.1:8765/api/status"
|
|
|
|
try {
|
|
Invoke-RestMethod -Uri $statusUrl -TimeoutSec 1 | Out-Null
|
|
}
|
|
catch {
|
|
$serverPath = Join-Path $PSScriptRoot "server.mjs"
|
|
$quotedServerPath = '"' + $serverPath + '"'
|
|
Start-Process -FilePath "node.exe" -ArgumentList @($quotedServerPath, "--port", "8765") -WindowStyle Hidden
|
|
|
|
$ready = $false
|
|
foreach ($attempt in 1..25) {
|
|
Start-Sleep -Milliseconds 100
|
|
try {
|
|
Invoke-RestMethod -Uri $statusUrl -TimeoutSec 1 | Out-Null
|
|
$ready = $true
|
|
break
|
|
}
|
|
catch {
|
|
# Retry while the local helper starts.
|
|
}
|
|
}
|
|
if (-not $ready) {
|
|
throw "Recipe editor service did not start on port 8765."
|
|
}
|
|
}
|
|
|
|
if (-not $NoOpen) {
|
|
Start-Process $url
|
|
}
|