I have installed & configured supervisor.
ps -ax shows 10 processes such as:
php /home/vagrant/Sites/mysite/artisan queue:work --tries=1
However when I put something in queue it stays there and nothing happens. But if I run this command manually (even under vagrant user, exactly how it does supervisor) everything works.
I use Redis for keeping queues.
What can be the reason?
update
So, here is some additional info, since I really couldn't figure it out.
Laravel 5.5 version
Actually I have two supervisor configs for 2 projects. First one seemed to be working. Second doesn't. I mean, I can see the processes by ps -ax, but nothing happens. Both configs are identical:
[program:mysite-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/vagrant/Sites/mysite/artisan queue:work --tries=1
autostart=true
autorestart=true
user=vagrant
numprocs=10
redirect_stderr=true
stdout_logfile=/home/vagrant/Sites/mysite/worker.log
Also I couldn't figure out how can I enable and disabled some configs (like en2site for supervisord :) )
So, when I put something in the queue I can see it in redis. Then I manually run php /home/vagrant/Sites/mysite/artisan queue:work --tries=1 under vagrant user and queue jobs are dispatched and run. But only if I run the command manually =\
I was about the same problem.
The issue is apears becouse supervisor when call
php /home/vagrant/Sites/mysite/artisan queue:work --tries=1
actualy not in project working directory, and artisan cant find .env file.
so you have some option to handle this:
set your enviroment variables from .env file
or
add directory parametr to your supervisor config
directory="path/to/your/project"
or
set set_include_path in php.ini to your project folder
Related
So I just faced this issue second time. First time I stopped that instance and created a new one as I coudn't resove it but happend the same in the second instance.
I was working on the Laravel queue and had to make the jobs run automatically so as per their document below I followed the steps.
https://laravel.com/docs/8.x/queues#supervisor-configuration
As soon as I run the "sudo supervisorctl update" command the whole instance stops working. SSH is also stop working so not sure how to resolve this issue.
The installation of supervisor and adding the laravel-worker.conf file works fine. Also the "sudo supervisorctl reread" works fine but as soon I run the update command, the whole instance stops working.
Please help.
updaing the Laravel-worker
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/mydomain.com/artisan queue:work
autostart=true
autorestart=true
user=ubuntu
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/mydomain.com/worker.log​
I don't know what exactly happened but when ever I start:
php artisan queue:work & redis-server.exe (windows)
I get a lot of processings for 1 event even tho app is not used (opened on browser)
I am not even using this Event from picture....
I am so unsure why is this happening?
Well using redis-cli flushall and queue:work --tries=1 helped me clean all proceses that were stored within redis and fail after one try.
I use the queue in my Laravel 5.4 project to send emails in background.
I have created the table for jobs, created the class for the job, and put QUEUE_DRIVER=database in my .env file. When I dispatch my Job, I can see my task in the jobs table. So far so good.
However, when I then execute the command
php artisan queue:work on the webserver - it's freezing and not have any results.
What could be the problem?
This probably is because this is a service that uses the current thread in Ubuntu (from your tag). If you add a &, the process will run in a forked thread.
php artisan queue:work &
Or after a quick google, you can have a look at
nohup php artisan queue:work --daemon &
Can someone know how can I run in one command to Laravel artisan work on all queue in project?
I know that I can run something like that nohup php artisan queue:work --queue=admin_contact_message_mail,user_get_message_notification,user_get_message_mail --daemon & , but I have a huge list of queues and asks is there any way to call it all in once or I need to list them all to queue run it and listen it?
php artisan queue:listen will do the job!
Here's an odd one. I'm running supervisor 3.13 with beanstalkd for a Laravel 4.1 queue. I have a /stage/ and /production/ instances of my app running. I'm running supervisor programs to run artisan queue:listen (out of separate .conf files) for each as follows:
[program:appname-production]
command=php artisan queue:listen --env=production
directory=/home/servername/public_html/production
stdout_logfile=/home/servername/public_html/production/app/storage/logs/supervisord.log
redirect_stderr=true
autostart=true
autorestart=true
The only difference is replacing production with stage in the program. However, when supervisor runs, only the stage program executes correctly. The production program shows FATAL Exited too quickly
appname-production FATAL Exited too quickly (process log may have details)
appname-stage RUNNING pid 6784, uptime 0:32:01
The stage queue is working fine as shown in ps aux. Also, running artisan queue:listen in the production folder works just as it should. When I examine the supervisord log for production however, it's full of:
X-Powered-By: PHP/5.5.20
Content-type: text/html
[InvalidArgumentException]
There are no commands defined in the "queue" namespace.
I've exhausted my technical knowledge of the setup here - I can't seem to reason out why two cloned setups are behaving differently. I've only been able to guess that supervisor is getting boggled somewhere - as I can get the production queue working fine by doing it manually.
All help / ideas are very appreciated.
Finally fixed this and wanted to share. Like other solutions, the fix had to do with setting an absolute path to php. However, the PATH var also needed to be set via environment in the subprocess conf. Here we go:
[program:appname]
command=/usr/local/bin/php artisan queue:listen --env=production
directory=/home/appdir
stdout_logfile=/home/appdir/app/storage/logs/supervisord.log
redirect_stderr=true
autostart=true
autorestart=true
environment=PATH="/usr/local/bin"
Hope this helps someone in the future!