feat: add Windows edge node launcher
This commit is contained in:
1 parent
da01967c2e
commit
57b00affbd
2 files changed
+100
No files matched your search
@@ -52,6 +52,22 @@ nvidia-smi
|
|||||||
|
|
||||||
If browser or network tests run from another machine, open the Windows firewall for ports 5173, 8080, 1935, and 8888.
|
If browser or network tests run from another machine, open the Windows firewall for ports 5173, 8080, 1935, and 8888.
|
||||||
|
|
||||||
|
## Windows edge node launcher
|
||||||
|
|
||||||
|
Build and start an edge node from a Windows edge machine:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\edge-agent\start-edge.ps1 -Build -OriginUrl http://<origin-host>:8080 -NodeId edge-win-01 -Region default -HlsPort 8889 -ApiPort 9997
|
||||||
|
```
|
||||||
|
|
||||||
|
For normal subsequent starts, omit `-Build`:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\edge-agent\start-edge.ps1 -OriginUrl http://<origin-host>:8080 -NodeId edge-win-01 -Region default -HlsPort 8889 -ApiPort 9997
|
||||||
|
```
|
||||||
|
|
||||||
|
The launcher sets the StreamCore edge environment variables, starts the Windows edge-agent executable, stores runtime data under `ProgramData\StreamCore\edge\<node-id>` by default, and writes logs to that node data directory. The edge agent then manages its embedded MediaMTX edge process.
|
||||||
|
|
||||||
## Edge node scripts
|
## Edge node scripts
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
param(
|
||||||
|
[string]$OriginUrl = "http://127.0.0.1:8080",
|
||||||
|
[string]$NodeId = "",
|
||||||
|
[string]$Region = "default",
|
||||||
|
[int]$HlsPort = 8889,
|
||||||
|
[int]$ApiPort = 9997,
|
||||||
|
[int]$Weight = 100,
|
||||||
|
[string]$DataDir = "",
|
||||||
|
[string]$ExePath = "",
|
||||||
|
[switch]$Build,
|
||||||
|
[switch]$NoWait
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
$Base = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
|
if (-not $NodeId) { $NodeId = $env:COMPUTERNAME }
|
||||||
|
if (-not $NodeId) { $NodeId = "windows-edge" }
|
||||||
|
if (-not $DataDir) { $DataDir = Join-Path $env:ProgramData ("StreamCore\edge\" + $NodeId) }
|
||||||
|
$LogDir = Join-Path $DataDir "logs"
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Force -Path $DataDir, $LogDir | Out-Null
|
||||||
|
|
||||||
|
function Assert-Command($Name, $Hint) {
|
||||||
|
if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
|
||||||
|
throw "$Name not found. $Hint"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Build) {
|
||||||
|
Assert-Command "go" "Install Go 1.19+ and make go.exe available in PATH."
|
||||||
|
Write-Host "[StreamCore Edge] Building Windows edge agent..."
|
||||||
|
& (Join-Path $Base "build.ps1")
|
||||||
|
}
|
||||||
|
|
||||||
|
$exeCandidates = @()
|
||||||
|
if ($ExePath) { $exeCandidates += $ExePath }
|
||||||
|
$exeCandidates += (Join-Path $Base "dist\streamcore-edge-windows-amd64.exe")
|
||||||
|
$exeCandidates += (Join-Path $Base "streamcore-edge.exe")
|
||||||
|
|
||||||
|
$ResolvedExe = $null
|
||||||
|
foreach ($candidate in $exeCandidates) {
|
||||||
|
if ($candidate -and (Test-Path $candidate)) {
|
||||||
|
$ResolvedExe = (Resolve-Path $candidate).Path
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $ResolvedExe) {
|
||||||
|
throw "Windows edge agent executable not found. Run: powershell -ExecutionPolicy Bypass -File .\edge-agent\start-edge.ps1 -Build"
|
||||||
|
}
|
||||||
|
|
||||||
|
$env:STREAMCORE_ORIGIN_URL = $OriginUrl
|
||||||
|
$env:STREAMCORE_NODE_ID = $NodeId
|
||||||
|
$env:STREAMCORE_REGION = $Region
|
||||||
|
$env:STREAMCORE_HLS_PORT = "$HlsPort"
|
||||||
|
$env:STREAMCORE_API_PORT = "$ApiPort"
|
||||||
|
$env:STREAMCORE_WEIGHT = "$Weight"
|
||||||
|
$env:STREAMCORE_DATA_DIR = $DataDir
|
||||||
|
|
||||||
|
Write-Host "[StreamCore Edge] Starting Windows edge node..."
|
||||||
|
Write-Host " Node ID: $NodeId"
|
||||||
|
Write-Host " Region: $Region"
|
||||||
|
Write-Host " Origin: $OriginUrl"
|
||||||
|
Write-Host " HLS: http://127.0.0.1:$HlsPort/"
|
||||||
|
Write-Host " API: http://127.0.0.1:$ApiPort/"
|
||||||
|
Write-Host " Data dir: $DataDir"
|
||||||
|
Write-Host " Logs: $LogDir"
|
||||||
|
|
||||||
|
$process = Start-Process -FilePath $ResolvedExe -WorkingDirectory $Base -PassThru -RedirectStandardOutput (Join-Path $LogDir "edge-agent.out.log") -RedirectStandardError (Join-Path $LogDir "edge-agent.err.log")
|
||||||
|
|
||||||
|
Write-Host "[StreamCore Edge] Process started with PID $($process.Id)."
|
||||||
|
if ($NoWait) { return }
|
||||||
|
|
||||||
|
Write-Host "Press Ctrl+C to stop the edge node."
|
||||||
|
try {
|
||||||
|
while (-not $process.HasExited) { Start-Sleep -Seconds 2 }
|
||||||
|
exit $process.ExitCode
|
||||||
|
} finally {
|
||||||
|
if (-not $process.HasExited) {
|
||||||
|
Write-Host "[StreamCore Edge] Stopping edge node..."
|
||||||
|
Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user