Files
compras/scripts/sgf-read-8039-cycle.ps1
2026-11-02 20:27:11 +02:00

17 lines
1.4 KiB
PowerShell

param([ValidateSet('apply','rollback','reapply')][string]$Action)
$ErrorActionPreference='Stop'
$demoRoot='C:/laragon/data/sgf-tempo/run/modular-regression-2576427d1939/development-app'
$demoPhp='C:/Users/macbook/.config/investmoz/php-8.5.11/php.exe'
$demoProcesses=Get-CimInstance Win32_Process | Where-Object {$_.Name -eq 'php.exe' -and $_.CommandLine -match '\s-S\s+127\.0\.0\.1:8039\s'}
foreach($demoProcess in $demoProcesses){
if($demoProcess.ExecutablePath -ne $demoPhp.Replace('/','\') -or $demoProcess.CommandLine -notmatch '-t public\s+scripts/router\.php'){throw 'Unexpected 8039 process'}
Stop-Process -Id $demoProcess.ProcessId
}
$operationOutput=& $demoPhp C:/laragon/www/compras/scripts/sgf-read-8039.php $Action
if($LASTEXITCODE -ne 0){throw 'Update/recovery failed; keep 8039 stopped and inspect private journal'}
$operationResult=($operationOutput -join "`n") | ConvertFrom-Json
if(-not $operationResult.deployment_id){throw 'Operation did not return a deployment receipt; retain stopped state'}
$operationOutput
$logRoot='C:/laragon/data/sgf-tempo/run/modular-regression-2576427d1939/private/read-correction-recovery'
Start-Process -FilePath $demoPhp -ArgumentList @('-S','127.0.0.1:8039','-t','public','scripts/router.php') -WorkingDirectory $demoRoot -WindowStyle Hidden -RedirectStandardOutput "$logRoot/$Action-out.log" -RedirectStandardError "$logRoot/$Action-error.log"