from pathlib import Path import json,shutil R=Path(__file__).resolve().parent.parent P=R/'storage/app/private/investmoz-v2/portal-audit' plan=json.loads((P/'consolidated-localservice-plan.json').read_text()) S=Path(plan['source']) assert S.parent==P and S.name.startswith('localservice-qa-') and plan['target']['port']==55441 shutil.copyfile(R/'tools/portal-consolidated-localservice-worker.php',S/'tools/localservice-worker.php') wrapper=r'''$ErrorActionPreference = 'Stop' $taskQa = Split-Path -Parent $PSScriptRoot $taskSid = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value if ($taskSid -ne 'S-1-5-19') { exit 19 } $taskProof = @{at=[DateTime]::UtcNow.ToString('o');pid=$PID;sid=$taskSid;name=[Security.Principal.WindowsIdentity]::GetCurrent().Name;qa_only=$true} $taskUtf8 = New-Object System.Text.UTF8Encoding($false) [IO.File]::AppendAllText((Join-Path $taskQa 'storage\qa-proof\principals.jsonl'), ($taskProof | ConvertTo-Json -Compress) + [Environment]::NewLine, $taskUtf8) & 'C:\laragon\bin\php\php-8.5.11-Win32-vs17-x64\php.exe' -c 'C:\laragon\bin\php\php-8.5.11-Win32-vs17-x64\php.ini' -d memory_limit=256M (Join-Path $PSScriptRoot 'localservice-worker.php') *> (Join-Path $taskQa 'storage\qa-proof\worker-console.txt') exit $LASTEXITCODE ''' (S/'tools/localservice-worker.ps1').write_text(wrapper,encoding='utf-8-sig') print(json.dumps({'result':'own_QA_service_worker_prepared','target':plan['target'],'active_writes':0}))