parent
cce8fd095a
commit
564529895f
6 changed files with 126 additions and 16 deletions
@ -0,0 +1,36 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Console\Commands; |
||||||
|
|
||||||
|
use Illuminate\Console\Command; |
||||||
|
use Illuminate\Support\Facades\Queue; |
||||||
|
|
||||||
|
class CheckQueue extends Command |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The name and signature of the console command. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $signature = 'queue:check'; |
||||||
|
|
||||||
|
/** |
||||||
|
* The console command description. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $description = 'Check if there is a job in the queue'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the console command. |
||||||
|
* |
||||||
|
* @return int |
||||||
|
*/ |
||||||
|
public function handle() |
||||||
|
{ |
||||||
|
$count = Queue::size(); // Get the number of jobs in the queue |
||||||
|
if ($count > 0) { |
||||||
|
$this->call('queue:process'); // Call the ProcessQueue command if there is a job in the queue |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Console\Commands; |
||||||
|
|
||||||
|
use Illuminate\Console\Command; |
||||||
|
use Illuminate\Support\Facades\Queue; |
||||||
|
|
||||||
|
class ProcessQueue extends Command |
||||||
|
{ |
||||||
|
/** |
||||||
|
* The name and signature of the console command. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $signature = 'queue:process'; |
||||||
|
|
||||||
|
/** |
||||||
|
* The console command description. |
||||||
|
* |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
protected $description = 'Process the tasks in the queue'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Execute the console command. |
||||||
|
* |
||||||
|
* @return int |
||||||
|
*/ |
||||||
|
public function handle() |
||||||
|
{ |
||||||
|
Queue::daemon(); // Process the tasks in the queue |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue