2

i implemented laravel queue in shared hosting by this steps:

1- I set this CronJob on the host for every minute:

* * * * * /usr/local/bin/php /home1/myuser/myfolder/artisan schedule:run >> /dev/null 2>&1

2- I set this command on kernel.php:

$schedule->command('queue:work --daemon')->withoutOverlapping();

and my queued jobs are working well

my question is: is it necessary to use queue:restart laravel command for "die" queues after they finish?

K1-Aria
  • 1,093
  • 4
  • 21
  • 34
  • 2
    Warning: withoutOverlapping has a default timeout of 1 day, so when your project runs for a while you will end up with tons of queue workers. – Alex Sep 15 '20 at 15:58
  • you mean i have to remove withoutOverlapping?? and its better for host resources?? so what is withoutOverlapping efficiency?? – K1-Aria Sep 17 '20 at 06:12
  • 1
    No, the best way would be use systemctl or supervisord to start / stop the queue. WithoutOverlapping might work with another parameter, but still I do not recommend this general approach – Alex Sep 19 '20 at 08:15
  • my hosting does not support supervisor. i have to use laravel scheduler – K1-Aria Sep 20 '20 at 08:24

1 Answers1

4

You do not have to kill queues after they finished (what is finished?). The queue worker runs all the jobs automatically. You do not even need a scheduler for that. Just run php artisan queue:work --daemon and everything happens automatically.

I think the critical point is when you update your laravel app or the queue worker stops for some reason (crashes).

About the updates: php artisan queue:work --daemon uses the instance of your app from when it was started, like php artisan tinker does aswell. If you don't stop your queue before updating, you usually end with many queue processes on your system, because the app will start new ones after updates. I'm not sure if these processes do any damage, but I would stop the queues. I would also encourage you to read https://laravel.com/docs/7.x/scheduling.

About the crash: At our company we are using a service that ensures that the php artisan queue:work process is running. Advantage here is that we can stop the service while updating.

Please correct me if i am wrong. I started the same way as the OP and this is were I am now :)

Flo Espen
  • 450
  • 4
  • 10