31 lines
1.2 KiB
PowerShell
31 lines
1.2 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
$repositoryRoot = Split-Path -Parent $PSScriptRoot
|
|
$venvPython = Join-Path $repositoryRoot ".venv\Scripts\python.exe"
|
|
$logRoot = Join-Path $repositoryRoot "artifacts\logs"
|
|
$logPath = Join-Path $logRoot "n7web-autostart.log"
|
|
|
|
if (-not (Test-Path -LiteralPath $venvPython -PathType Leaf)) {
|
|
throw "N7Web Python executable not found: $venvPython"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Path $logRoot -Force | Out-Null
|
|
$python = (& $venvPython -c "import sys; print(sys._base_executable)").Trim()
|
|
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $python -PathType Leaf)) {
|
|
throw "N7Web base Python executable could not be resolved."
|
|
}
|
|
$env:PYTHONPATH = @(
|
|
(Join-Path $repositoryRoot "src")
|
|
(Join-Path $repositoryRoot "domains\seat\src")
|
|
) -join [System.IO.Path]::PathSeparator
|
|
|
|
while ($true) {
|
|
& $python -m cognitive_agent.firmware_ota_server --host 127.0.0.1 --port 8012 *>> $logPath
|
|
$exitCode = $LASTEXITCODE
|
|
$timestamp = Get-Date -Format "yyyy-MM-ddTHH:mm:ssK"
|
|
Add-Content -LiteralPath $logPath -Value (
|
|
"[$timestamp] OTA service exited with code $exitCode; restarting in 2 seconds."
|
|
)
|
|
Start-Sleep -Seconds 2
|
|
}
|