-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Feature - added artisan command to clear the queue
- Loading branch information
Showing
3 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.