Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php artisan queue:work doesn't work with supervisor

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 =\

like image 415
Victor Avatar asked Mar 17 '26 21:03

Victor


1 Answers

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:

  1. set your enviroment variables from .env file or
  2. add directory parametr to your supervisor config directory="path/to/your/project" or
  3. set set_include_path in php.ini to your project folder
like image 143
Artem Rusinov Avatar answered Mar 20 '26 10:03

Artem Rusinov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!