简体   繁体   中英

Laravel 4 and Beanstalkd

I now have a stable Beanstalkd and Laravel 4 Queue setup running on one machine. My question is, how can I install the Laravel 4 workers on a second machine and make them listen to my Beanstalkd? Maybe a very obvious question to some but I can't figure it out. I noticed there was a connection field in the php artisan queue:listen command. Do I have to use that?

how can I install the Laravel 4 workers on a second machine and make them listen to my Beanstalkd?

You'll need to have a working instance of your laravel application on the same server as the listener/workers.

This means deploying your application both to the web server and to server that is listening for jobs.

Then, on the listening server, you can call php artisan queue:listen in order to listen for new jobs and create a worker to handle the job.

I noticed there was a connection field in the php artisan queue:listen command. Do I have to use that?

On top of the above question, and similar to most artisan commands, you will likely also need to define which environment the queue:listen command should use:

$ php artisan queue:listen --env=production

In this way, your laravel app that is used to handle the workers (the app on the listening server) will know what configurations to use, including knowing what database credentials to use. This also likely means that both the web server and your job/listening server needs to have access to your database .

Lastly, you could also create 2 separate Laravel applications - One for your web application and one purely to handle processing job. Then they could each have their own configuration, and you'll have 2 (probably smaller?) code bases. But still, you'll have 2 code bases instead of 1.

In that regard, do whatever works best for your situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM