We are running our production system on Elastic Beanstalk. We want to be able to take advantage of EBS' worker tiers with autoscaling. Unfortunately, due to how Laravel queue processing works, Laravel expects all queues to be consumed by starting a php command line process on your servers. EBS worker tiers don't function that way. AWS installs a listener daemon of its own, that pulls of jobs and feeds them to your worker over local HTTP calls. Sounds great. Unfortunately, I can't figure out how one would call a queued job from a route and controller in Laravel instead of using the built-in artisan queue listener task. Any clues as to how to achieve this would be greatly appreciated.
Asked
Active
Viewed 9,716 times
4
-
why not use php's `shell_exec` ? – Derek Pollard Feb 04 '16 at 20:03
-
1@OliverQueen I try to avoid things like `shell_exec`, `eval` and the like because it makes code harder to debug and more prone to security issues. Also it can cause portability issues if you want to run your code on multiple OS types. (not that OP is, just something to keep in mind) – jfadich Feb 04 '16 at 20:06
2 Answers
6
You can use the Artisan::call
method to call commands from code.
$exitCode = Artisan::call('queue:work');
You can see more info in the docs

jfadich
- 6,110
- 2
- 20
- 31
-
I am not trying to call the artisan task. I am trying to process the jobs. – Sam McAfee Feb 04 '16 at 20:18
-
But won't calling the artisan take still process your jobs? You can put that code in the controller that AWS will call. – jfadich Feb 04 '16 at 20:24
-
1