diff --git a/.gitignore b/.gitignore index a632c2b..c2e4b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ report_assets/ report_render_runtime/ 系统部署性能分析评估报告.docx monitor_runtime/local-webcam/ +/git-manager.ps1 +/git-manager.ps1 diff --git a/config.json b/config.json index c081632..4888dbb 100644 --- a/config.json +++ b/config.json @@ -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", @@ -40,4 +40,4 @@ "rtpTransferAudioType": 0, "autoInviteAfterRecCateLog": true } -} +} \ No newline at end of file diff --git a/scripts/start-local-lan.ps1 b/scripts/start-local-lan.ps1 new file mode 100644 index 0000000..4286856 --- /dev/null +++ b/scripts/start-local-lan.ps1 @@ -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 +}