Skip to content

Commit 866185d

Browse files
committed
fix: stream sqs queue process output
1 parent d3991fa commit 866185d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Lambda/Handler/Sqs/AbstractIlluminateQueueSqsHandler.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ final protected function processRecord(InvocationContext $context, SqsRecord $re
7171

7272
$process = new Process($arguments);
7373
$process->setTimeout(null);
74-
$process->run();
74+
$process->run(function (string $type, string $output): void {
75+
$this->writeProcessOutput($type, $output);
76+
});
7577

7678
if ($process->isSuccessful()) {
7779
return;
@@ -86,6 +88,14 @@ final protected function processRecord(InvocationContext $context, SqsRecord $re
8688
throw new SqsRecordProcessingException(sprintf('%s queue job failed', $this->getQueueName()), $output);
8789
}
8890

91+
/**
92+
* Write the queue process output.
93+
*/
94+
protected function writeProcessOutput(string $type, string $output): void
95+
{
96+
fwrite(Process::ERR === $type ? STDERR : STDOUT, $output);
97+
}
98+
8999
/**
90100
* Get queue process arguments.
91101
*

0 commit comments

Comments
 (0)