laravel queue 3awork freezes

Solutions on MaxInterview for laravel queue 3awork freezes by the best coders in the world

showing results for - "laravel queue 3awork freezes"
Petunia
12 Apr 2018
1//laravel
2//Execute Laravel queues by queue names on command line interface-> 
3// I was using running command
4  'php artisan queue:work'    
5// which was not running my queued jobs in jobs table. 
6// Then i relaized, it was only working for jobs with queue column value = 'default'
7// and  i had given names like sendemail, inboxemail etc. to queues while dispatching jobs (->onQueue('sendemail'))
8  
9// So when i changed this other value to  'default'  in queue column in jobs table,
10// this job ran instantly as i have opended cli and  php artisan queue:work 
11// command was active.  
12  
13//So if you want to run only a specific queue by queue name, run command ->
14  php artisan queue:work --queue=sendemail 
15//    or
16  php artisan queue:listen --queue=sendemail 
17//here, sendemail is the name of queue i have given while using  ->onQueue('sendemail')
18//while dispatching a job    
19//you can google difference between  queue:work and queue:listen, however queue:work is good to use    
20
21//Now, if you want to automate these queues in background, so that you dont 
22//have to get back to cli every time you want to execute these queues, use
23//supervisor    
24//supervisor commands -> use these commands in php root folder, not inside laravel project
25sudo apt-get install supervisor  or  sudo yum install supervisor
26//then you need to make changes to installed   /etc/supervisord.conf  file where
27//you find below code starting with [program:laravel-worker] or paste below code if 
28//it is not there    
29[program:laravel-worker]
30process_name=%(program_name)s_%(process_num)02d
31command=php /path to your laravel project/artisan queue:work database --tries=2 --queue=default,otherqueuename,anyotherqueuename
32autostart=true
33autorestart=true
34;user=forge
35numprocs=1
36redirect_stderr=true
37stdout_logfile=/path to your laravel project/worker.log
38//worker.log file will get updated with all the queues that supervisor executes  
39  
40//commands to start , stop supervisor, so you can check jobs queues in database
41//in jobs table if you are actually having jobs to be processed by supervisor  
42sudo service supervisord restart  
43sudo service supervisord stop
44