Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running laravel queue:work on a shared hosting

I want my laravel queue:work to keep running on a shared hosting, this is a shared hosting (am not on a VPS) I can't install anything because almost all online sources when I was searching for this suggest installing supervisor. So basically I thought I could just create a cron job that checks if queue is not running and starts it, any help on how to go about this because am kinda stuck, thanks.

P.S. Am on a Linux server and Laravel 5.3

like image 771
lulliezy Avatar asked Sep 10 '17 14:09

lulliezy


2 Answers

With Laravel 8 you have the option --max-time for queue:work that allows it to stop job processing after some amount of time.

php artisan queue:work --max-time=300

You can setup a cron job, for example, every 5 minutes to run job processing and set the --max-time option to 5 minutes (300 seconds). In that case, cron will run job processing, after 300 seconds queue:work will exit, and, in a couple of seconds, cron will run job processing again, and so on.

like image 163
artem Avatar answered Sep 21 '22 20:09

artem


As you mentioned you are using shared hosting, You follow the below steps.

Step 1. you need to setup your queue driver as database

Step 2 you need to setup a cron job with with the following command php /path/to/application/artisan queue:work --queue=high,default.

You can give a try. I hope it will work.

like image 45
Suresh Velusamy Avatar answered Sep 17 '22 20:09

Suresh Velusamy