4

I send email on my script with laravel queue.
I need to run php artisan queue:work on my script for run laravel queue. I want to monitor if this php artisan queue:work failed, I run again. My solution is command like this on corn job

class Kernel extends ConsoleKernel
{
     protected function schedule(Schedule $schedule)
     {
              if(check queue failed)
              $schedule->command("php artisan queue:work")->cron("* * * * *");
     }
}

I have two question
1- what condition I should use instead of check queue failed
2- Is there any better solution?

paranoid
  • 6,799
  • 19
  • 49
  • 86

1 Answers1

3

This is what I did, following some tutorials online; it works fine and is not creating more instances

$schedule->command('queue:work --queue=high,low --tries=3')
    ->everyMinute()
    ->withoutOverlapping();

The important part is ->withoutOverlapping(), which will execute the command again if it is not running anymore. I still have to find a way to test what happens if it hangs, hopefully someone else can improve this answer

clod986
  • 2,527
  • 6
  • 28
  • 52