laravel queue:work freezes

Execute Laravel queues by queue names on command line interface-> 
// I was using running command
  'php artisan queue:work'    
// which was not running my queued jobs in jobs table. 
// Then i relaized, it was only working for jobs with queue column value = 'default'
// and  i had given names like sendemail, inboxemail etc. to queues while dispatching jobs (->onQueue('sendemail'))
  
// So when i changed this other value to  'default'  in queue column in jobs table,
// this job ran instantly as i have opended cli and  php artisan queue:work 
// command was active.  
  
//So if you want to run only a specific queue by queue name, run command ->
  php artisan queue:work --queue=sendemail 
//    or
  php artisan queue:listen --queue=sendemail 
//here, sendemail is the name of queue i have given while using  ->onQueue('sendemail')
//while dispatching a job    
//you can google difference between  queue:work and queue:listen, however queue:work is good to use    

//Now, if you want to automate these queues in background, so that you dont 
//have to get back to cli every time you want to execute these queues, use
//supervisor    
//supervisor commands -> use these commands in php root folder, not inside laravel project
sudo apt-get install supervisor  or  sudo yum install supervisor
//then you need to make changes to installed   /etc/supervisord.conf  file where
//you find below code starting with [program:laravel-worker] or paste below code if 
//it is not there    
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /path to your laravel project/artisan queue:work database --tries=2 --queue=default,otherqueuename,anyotherqueuename
autostart=true
autorestart=true
;user=forge
numprocs=1
redirect_stderr=true
stdout_logfile=/path to your laravel project/worker.log
//worker.log file will get updated with all the queues that supervisor executes  
  
//commands to start , stop supervisor, so you can check jobs queues in database
//in jobs table if you are actually having jobs to be processed by supervisor  
sudo service supervisord restart  
sudo service supervisord stop
    

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source