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?
New code examples in category PHP
-
PHP 2022-03-27 22:40:03 index:of curiosa 2019 mp4
-
PHP 2022-03-27 22:35:13 Dijkstra’s algorithm php
-
PHP 2022-03-27 22:35:12 get_declared_classes
-
PHP 2022-03-27 22:30:23 php move index of a value to first position in array
-
PHP 2022-03-27 22:25:01 wordpress get_date
-
PHP 2022-03-27 21:30:38 php shorten string with dots
-
PHP 2022-03-27 21:10:46 php header 500
-
PHP 2022-03-27 21:05:06 laravel schedule run
-
PHP 2022-03-27 20:25:12 Get page title, excerpt or content by id
-
PHP 2022-03-27 20:00:27 php convert date from dd/mm/yyyy to yyyy-mm-dd