Files
Investidor-V2/tools/portal-service-followup-worker-qa.php
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

26 lines
2.1 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');
$app=(static fn($p)=>require $p)(__DIR__.'/portal-service-followup-runtime.php');
$root=dirname(__DIR__);$dir=$root.'/storage/app/private/investmoz-v2/portal-audit';
throw_unless(config('database.connections.pgsql.port')==55441 && config('queue.connections.database.queue')==='services-followup-qa',RuntimeException::class,'Exclusive isolated QA queue required');
$receipt=$dir.'/service-followup-worker-interruption-qa.json';
if(!is_file($receipt)){
$job=app('queue')->connection()->pop('services-followup-qa');
throw_unless($job && $job->resolveName()===App\Jobs\ScanDocumentForMalware::class,RuntimeException::class,'Only synthetic scan may be reserved');
file_put_contents($receipt,json_encode(['started_at'=>gmdate('c'),'pid'=>getmypid(),'job_id'=>$job->getJobId(),'attempts'=>$job->attempts(),
'target'=>config('database.connections.pgsql.database').':55441','queue'=>'services-followup-qa','injected_stall_seconds'=>300,
'original_job_preserved'=>true,'active_queue_consumed'=>0],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));
sleep(300); // The real Task Scheduler must stop this own QA process at its 180-second limit.
file_put_contents($dir.'/service-followup-watchdog-failed-to-stop.json','{"result":"failed"}');
exit(71);
}
$started=['at'=>gmdate('c'),'pid'=>getmypid(),'php_process_memory_limit'=>ini_get('memory_limit'),'sapi'=>PHP_SAPI];
file_put_contents($dir.'/service-followup-worker-invocations-qa.jsonl',json_encode($started,JSON_THROW_ON_ERROR).PHP_EOL,FILE_APPEND);
$status=$app->handleCommand(new Symfony\Component\Console\Input\ArrayInput([
'command'=>'queue:work','connection'=>'database','--queue'=>'services-followup-qa','--once'=>true,
'--tries'=>3,'--timeout'=>150,'--memory'=>256,'--no-interaction'=>true]));
file_put_contents($dir.'/service-followup-worker-completions-qa.jsonl',json_encode([
'at'=>gmdate('c'),'pid'=>getmypid(),'target'=>config('database.connections.pgsql.database').':55441',
'status'=>$status,'memory_limit'=>ini_get('memory_limit'),'peak_bytes'=>memory_get_peak_usage(true)],JSON_THROW_ON_ERROR).PHP_EOL,FILE_APPEND);
exit($status);