fix: start mediamtx from its own directory so it finds mediamtx.yml
This commit is contained in:
parent
a1143562c4
commit
248f62ca5d
@ -15,7 +15,7 @@ $edgeDir = (Resolve-Path (Join-Path $controlDir "..\safesight-edge")).Path
|
||||
|
||||
# ── paths ──────────────────────────────────────────────
|
||||
$mediamtx = "C:\Software\mediamtx\mediamtx.exe"
|
||||
$mediamtxConf = "C:\Software\mediamtx\mediamtx.yml"
|
||||
$mediamtxDir = "C:\Software\mediamtx"
|
||||
$ffmpeg = "ffmpeg"
|
||||
$minio = "C:\Users\Tellme\minio\minio.exe"
|
||||
$minioData = "C:\Users\Tellme\minio\myminio"
|
||||
@ -37,7 +37,7 @@ function Write-Banner {
|
||||
}
|
||||
|
||||
function Start-Detached {
|
||||
param([string]$Name, [string]$Exe, [string[]]$Args, [switch]$Visible)
|
||||
param([string]$Name, [string]$Exe, [string[]]$Args, [switch]$Visible, [string]$WorkDir)
|
||||
$exePath = $Exe
|
||||
if (-not (Test-Path $Exe)) {
|
||||
$cmd = Get-Command $Exe -ErrorAction SilentlyContinue
|
||||
@ -49,11 +49,10 @@ function Start-Detached {
|
||||
}
|
||||
Write-Host " [START] $Name ($exePath)" -ForegroundColor Green
|
||||
$style = if ($Visible) { "Normal" } else { "Minimized" }
|
||||
if ($Args -and $Args.Count -gt 0) {
|
||||
$proc = Start-Process -FilePath $exePath -ArgumentList $Args -WindowStyle $style -PassThru
|
||||
} else {
|
||||
$proc = Start-Process -FilePath $exePath -WindowStyle $style -PassThru
|
||||
}
|
||||
$procArgs = @{FilePath=$exePath; WindowStyle=$style; PassThru=$true}
|
||||
if ($WorkDir) { $procArgs.WorkingDirectory = $WorkDir }
|
||||
if ($Args -and $Args.Count -gt 0) { $procArgs.ArgumentList = $Args }
|
||||
$proc = Start-Process @procArgs
|
||||
Start-Sleep -Milliseconds 500
|
||||
return $proc
|
||||
}
|
||||
@ -73,7 +72,7 @@ function Stop-ByName {
|
||||
function Invoke-Start {
|
||||
# 1. RTSP server
|
||||
Write-Banner "1/5 RTSP Server (mediamtx)"
|
||||
Start-Detached "mediamtx" $mediamtx @($mediamtxConf)
|
||||
Start-Detached "mediamtx" $mediamtx -WorkDir $mediamtxDir
|
||||
Write-Host " [WAIT] 等待 RTSP 服务就绪..." -ForegroundColor DarkGray
|
||||
$ready = $false
|
||||
for ($i = 0; $i -lt 10; $i++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user