Skip to content

Instantly share code, notes, and snippets.

@martin-ro
Created January 24, 2025 20:35
Show Gist options
  • Save martin-ro/730a25917b34067251a02d35f42ad7d3 to your computer and use it in GitHub Desktop.
Save martin-ro/730a25917b34067251a02d35f42ad7d3 to your computer and use it in GitHub Desktop.
ClearHorizonCommand
<?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