Files
SGF/scripts/stop-selected-sgf-server.ps1
T
2026-11-11 09:00:17 +02:00

16 lines
1.6 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$sgfRun = Get-Content -LiteralPath 'C:/laragon/data/sgf-tempo/run/modular-regression-current.json' -Raw | ConvertFrom-Json
if ($sgfRun.id -ne '2576427d1939') { throw 'Instalação diferente; nada foi parado.' }
$sgfRoot = Join-Path $sgfRun.root 'private/receipt-composition-cc50a276c10c'
$sgfState = Get-Content -LiteralPath (Join-Path $sgfRoot 'state.json') -Raw | ConvertFrom-Json
$sgfServer = Get-Content -LiteralPath (Join-Path $sgfRoot 'demo-server.json') -Raw | ConvertFrom-Json
if ($sgfState.tag -ne 'cc50a276c10c' -or !$sgfState.singleInstallation -or $sgfServer.port -ne 8085) { throw 'Destino diferente; nada foi parado.' }
$sgfProcess = Get-CimInstance Win32_Process -Filter ('ProcessId = '+[int]$sgfServer.pid)
$sgfPublic = (Join-Path $sgfState.app 'public').Replace([char]92,[char]47).ToLowerInvariant() -replace '/+','/'
$sgfExecutable = if ($sgfProcess) { $sgfProcess.ExecutablePath.Replace([char]92,[char]47).ToLowerInvariant() -replace '/+','/' } else { '' }
if (!$sgfProcess -or $sgfExecutable -ne 'c:/laragon/tools/sgf-tempo/php-8.4.27/php.exe') { throw 'Processo diferente; nada foi parado.' }
$sgfCommand = $sgfProcess.CommandLine.Replace([char]92,[char]47).ToLowerInvariant() -replace '/+','/'
if (!$sgfCommand.Contains('127.0.0.1:8085') -or !$sgfCommand.Contains($sgfPublic) -or !$sgfCommand.Contains('scripts/receipt-composition-http.php')) { throw 'Comando diferente; nada foi parado.' }
Stop-Process -Id ([int]$sgfServer.pid) -ErrorAction Stop
Write-Output 'Foi parado apenas o processo PHP conferido da8085; bases e restantes servidores não foram parados.'