Created
January 24, 2025 20:35
-
-
Save martin-ro/730a25917b34067251a02d35f42ad7d3 to your computer and use it in GitHub Desktop.
ClearHorizonCommand
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
<?php | |
namespace App\Console\Commands; | |
use DB; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Artisan; | |
use Illuminate\Support\Facades\Redis; | |
class ClearHorizonCommand extends Command | |
{ | |
protected $signature = 'horizon:clear-all'; | |
public function handle(): void | |
{ | |
Redis::connection(name: 'horizon')->client()->flushAll(); | |
DB::table('job_batches')->delete(); | |
Redis::connection()->del([config('horizon.prefix').'failed:*']); | |
Redis::connection()->del([config('horizon.prefix').'failed_jobs']); | |
Artisan::call('horizon:terminate'); | |
$this->info('Horizon cleared & restarted.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment