Skip to content

Commit ae955ad

Browse files
committed
add json option to queue:monitor
1 parent fb07c86 commit ae955ad

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Illuminate/Queue/Console/MonitorCommand.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class MonitorCommand extends Command
1919
*/
2020
protected $signature = 'queue:monitor
2121
{queues : The names of the queues to monitor}
22-
{--max=1000 : The maximum number of jobs that can be on the queue before an event is dispatched}';
22+
{--max=1000 : The maximum number of jobs that can be on the queue before an event is dispatched}
23+
{--json : Output the queue size as JSON}';
2324

2425
/**
2526
* The console command description.
@@ -65,7 +66,15 @@ public function handle()
6566
{
6667
$queues = $this->parseQueues($this->argument('queues'));
6768

68-
$this->displaySizes($queues);
69+
if ($this->option('json')) {
70+
$this->output->writeln((new Collection($queues))->map(function ($queue) {
71+
return array_merge($queue, [
72+
'status' => str_contains($queue['status'], 'ALERT') ? 'ALERT' : 'OK',
73+
]);
74+
})->toJson());
75+
} else {
76+
$this->displaySizes($queues);
77+
}
6978

7079
$this->dispatchEvents($queues);
7180
}

0 commit comments

Comments
 (0)