param([ValidateSet('apply','apply-code')][string]$Action='apply') $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' foreach($process in (Get-CimInstance Win32_Process | Where-Object {$_.Name -eq 'php.exe' -and $_.CommandLine -match '\s-S\s+127\.0\.0\.1:8039\s'})){ if($process.ExecutablePath -ne $demoPhp.Replace('/','\') -or $process.CommandLine -notmatch '-t public\s+scripts/router\.php'){throw 'Unexpected 8039 web process'} Stop-Process -Id $process.ProcessId } $output=& $demoPhp C:/laragon/www/compras/scripts/sgf-sourcing-demo.php $Action if($LASTEXITCODE -ne 0){throw 'Sourcing preparation failed; keep demonstration closed and inspect recovery'} $result=($output -join "`n")|ConvertFrom-Json if(-not $result.applied){throw 'No valid application receipt'} $output $logs='C:/laragon/data/sgf-tempo/run/modular-regression-2576427d1939/private/sourcing-recovery' Start-Process -FilePath $demoPhp -ArgumentList @('-S','127.0.0.1:8039','-t','public','scripts/router.php') -WorkingDirectory $demoRoot -WindowStyle Hidden -RedirectStandardOutput "$logs/$Action-server-out.log" -RedirectStandardError "$logs/$Action-server-error.log"