备份:局域网启动配置调整(大规模修改前状态点)

This commit is contained in:
zhaotieling 2026-09-08 05:04:22 +08:00
parent c6fdc7fe10
commit 8d91ceb5d6
3 changed files with 77 additions and 2 deletions

2
.gitignore vendored
View File

@ -60,3 +60,5 @@ report_assets/
report_render_runtime/
系统部署性能分析评估报告.docx
monitor_runtime/local-webcam/
/git-manager.ps1
/git-manager.ps1

View File

@ -29,7 +29,7 @@
"recordingRetainDays": 7,
"recordingRetainGb": 0.0,
"sipServer": {
"sipServerIp": "192.168.1.60",
"sipServerIp": "192.168.1.127",
"sipServerPort": 15060,
"sipTransferMode": 0,
"sipServerId": "34020000002000000001",

View File

@ -0,0 +1,73 @@
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
}