Listener
class Listener
Traits
Properties
| protected string | $environment | The environment the workers should run under. |
|
| protected int | $sleep | The amount of seconds to wait before polling the queue. |
|
| protected int | $maxTries | The number of times to try a job before logging it failed. |
|
| protected Closure|null | $outputHandler | The output handler callback. |
Methods
Stop the process if its output callback fails.
Create a new queue listener.
Get the PHP binary.
Get the Artisan binary.
Listen to the given queue connection.
Create a new Symfony process for the worker.
Add the environment option to the given command.
Create the command with the listener options.
Run the given process.
Handle output from the worker process.
Determine if the memory limit has been exceeded.
Stop listening and bail out of the script.
Details
in
GuardsProcessOutput at line 17
protected Closure|null
guardProcessOutput(Process $process, callable|null $output)
Stop the process if its output callback fails.
at line 43
__construct(string $commandPath)
Create a new queue listener.
at line 51
protected string
phpBinary()
Get the PHP binary.
at line 59
protected string
artisanBinary()
Get the Artisan binary.
at line 67
void
listen(string|null $connection, string $queue, ListenerOptions $options)
Listen to the given queue connection.
at line 83
Process
makeProcess(string|null $connection, string $queue, ListenerOptions $options)
Create a new Symfony process for the worker.
at line 110
protected array
addEnvironment(array $command, ListenerOptions $options)
Add the environment option to the given command.
at line 118
protected array
createCommand(string|null $connection, string $queue, ListenerOptions $options)
Create the command with the listener options.
at line 141
void
runProcess(Process $process, float|string $memory)
Run the given process.
at line 158
protected void
handleWorkerOutput(string $type, string $line)
Handle output from the worker process.
at line 168
bool
memoryExceeded(float|string $memoryLimit)
Determine if the memory limit has been exceeded.
at line 178
never
stop()
Stop listening and bail out of the script.
at line 189
void
setOutputHandler(Closure $outputHandler)
Set the output handler callback.
The callback persists on the singleton listener for the command lifetime and handles every subsequent worker output line.