74 lines
2.3 KiB
PowerShell
74 lines
2.3 KiB
PowerShell
param(
|
|
[string]$LanIp = ''
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$projectRoot = Split-Path -Parent $PSScriptRoot
|
|
$python = Join-Path $projectRoot '.venv\Scripts\python.exe'
|
|
|
|
if (-not (Test-Path -LiteralPath $python -PathType Leaf)) {
|
|
throw "Project virtual environment was not found: $python"
|
|
}
|
|
|
|
if ([string]::IsNullOrWhiteSpace($LanIp)) {
|
|
$network = Get-NetIPConfiguration |
|
|
Where-Object {
|
|
$_.NetAdapter.Status -eq 'Up' -and
|
|
$_.IPv4DefaultGateway -and
|
|
$_.IPv4Address.IPAddress -notlike '127.*' -and
|
|
$_.IPv4Address.IPAddress -notlike '169.254.*' -and
|
|
$_.IPv4Address.IPAddress -notlike '198.18.*'
|
|
} |
|
|
Select-Object -First 1
|
|
|
|
if (-not $network) {
|
|
throw 'No active LAN IPv4 address was found. Pass one explicitly, for example: .\start-local-lan.ps1 -LanIp 192.168.1.10'
|
|
}
|
|
$LanIp = $network.IPv4Address.IPAddress
|
|
}
|
|
|
|
$parsedIp = $null
|
|
if (-not [System.Net.IPAddress]::TryParse($LanIp, [ref]$parsedIp) -or
|
|
$parsedIp.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) {
|
|
throw "Invalid IPv4 address: $LanIp"
|
|
}
|
|
|
|
$runtime = Join-Path $projectRoot '.runtime'
|
|
$yoloConfig = Join-Path $runtime 'ultralytics'
|
|
New-Item -ItemType Directory -Path $yoloConfig -Force | Out-Null
|
|
|
|
$ffmpeg = (& $python -c "import imageio_ffmpeg; print(imageio_ffmpeg.get_ffmpeg_exe())").Trim()
|
|
if (-not (Test-Path -LiteralPath $ffmpeg -PathType Leaf)) {
|
|
throw "FFmpeg executable was not found: $ffmpeg"
|
|
}
|
|
|
|
$env:DJANGO_SETTINGS_MODULE = 'framework.settings'
|
|
$env:MONITOR_DEBUG = 'true'
|
|
$env:MONITOR_ALLOWED_HOSTS = "127.0.0.1,localhost,$LanIp"
|
|
$env:MONITOR_CSRF_TRUSTED_ORIGINS = "http://${LanIp}:10001"
|
|
$env:MONITOR_HTTPS = 'false'
|
|
$env:MONITOR_SERVICE_MODE = 'disabled'
|
|
$env:MONITOR_BOOTSTRAP_SERVICES = 'false'
|
|
$env:MONITOR_TELEMETRY_ENDPOINT = ''
|
|
$env:MONITOR_UPDATE_ENDPOINT = ''
|
|
$env:MONITOR_FFMPEG = $ffmpeg
|
|
$env:PYTHONUNBUFFERED = '1'
|
|
$env:YOLO_CONFIG_DIR = $yoloConfig
|
|
$env:YOLO_OFFLINE = 'true'
|
|
$env:YOLO_AUTOINSTALL = 'false'
|
|
$env:CI = 'true'
|
|
|
|
Write-Host "Starting LAN development server..."
|
|
Write-Host "Local: http://127.0.0.1:10001/login"
|
|
Write-Host "LAN: http://${LanIp}:10001/login"
|
|
Write-Host 'Press Ctrl+C to stop.'
|
|
|
|
Push-Location $projectRoot
|
|
try {
|
|
& $python 'manage.py' 'runserver' '0.0.0.0:10001' '--noreload'
|
|
exit $LASTEXITCODE
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|