I have installed beanstaled and its working fine with laravel. The point where I am puzzled is that we have to do
php artisan queue:listen
to start listening queue. Right now, I am using it on amazone ec2 instance remotely through putty. but what is i close terminal? Will the jobs created through the code will work? Is it manually calling php artisan queue:listen
or php artisan queue:work
all time. Which does not seems fair.
If once php artisan queue:listen
done, will it keep on running even if we close terminal?
Actually I dont know.
Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time.
Running this simple command should do the trick: php artisan queue:restart. It works by setting a illuminate:queue:restart key in your cache store that holds the timestamp of when the command ran. After workers finish each job, they check for that key and see if it was updated since the last time they checked.
php artisan queue:listen. The queue:listen command simply runs the queue:work --once command inside an infinite loop, this will cause the following: An instance of the app is booted up on every loop. The assigned worker will pick a single job and execute it. The worker process will be killed.
Show activity on this post. This is lower level but in the same vein you could run a command such as ps -aux | grep queue to literally view the running queue processes on whatever server your application/queue workers are running on.
you need to install supervisor also. Here is a tutorial on using beanstalkd with laravel:
http://fideloper.com/ubuntu-beanstalkd-and-laravel4
Here are details on supervisor also:
http://supervisord.org/installing.html
I personally use a redis instance and run my queue with supervisor from there. I find its a bit more memory effective then beanstalkd personally but each to there own.
Supervisor will execute the queue:listen command from artisan and this will run a job, if you have multiple supervisor processes then you can run multiple in line items. depending on what you are doing i would almost look into python and multithereading also as i have used this for a few things i used to use a queue for and it has provided even better results.
example config file for supervisor:
[program:myqueue]
command=php artisan queue:listen --env=your_environment
directory=/path/to/laravel
stdout_logfile=/path/to/laravel/app/storage/logs/myqueue_supervisord.log
redirect_stderr=true
autostart=true
autorestart=true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With