Skip to content

Commit

Permalink
🚀 Feature - added artisan command to clear the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenMelbz committed May 25, 2020
1 parent 1d1ca1c commit 2afadb9
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
66 changes: 66 additions & 0 deletions app/Console/Commands/ResetQueueStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace App\Console\Commands;

use App\Website;
use Illuminate\Console\Command;
use Morrislaptop\LaravelQueueClear\Contracts\Clearer as ClearerContract;

class ResetQueueStatus extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'queue:reset';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Resets the queue status within the database';

/**
* @var ClearerContract
*/
private $clearer;

/**
* Create a new command instance.
*
* @param ClearerContract $clearer
*/
public function __construct(ClearerContract $clearer)
{
$this->clearer = $clearer;
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Website::query()->update([
'in_queue_og' => 0,
'in_queue_robots' => 0,
'in_queue_ssl' => 0,
'in_queue_crawler' => 0,
'in_queue_dns' => 0,
'in_queue_uptime' => 0,
]);

$cleared = $this->clearer->clear('redis', 'default');
$this->info(sprintf('Cleared %d jobs on "default"', $cleared));

$cleared = $this->clearer->clear('redis', 'default_long');
$this->info(sprintf('Cleared %d jobs on "default_long"', $cleared));

$this->info('Queue statuses all reset!');
$this->call('queue:flush');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"laravel/horizon": "^3.3",
"laravel/tinker": "^1.0",
"maelstrom-cms/toolkit": "^1.0",
"morrislaptop/laravel-queue-clear": "^1.2",
"owenmelbz/domain-enforcement": "^0.0.6",
"predis/predis": "^1.1",
"sebastian/diff": "^3.0",
Expand Down
43 changes: 42 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2afadb9

Please sign in to comment.