Hy!
Can you make multithreadding in Laravel 5.2 by default? I'm currently using Jobs
and Queues
, but queue:listen
or queue:work
run only one job at time. I need a method that is made in code, not like Supervisor
. So run the cron, and if there are 4 jobs waiting, run them async.
As I mentioned in title, I also agree multi process, but I have no idea how it work. I've tried to put those commands in a loop, but still take just one job at time.
public function handle()
{
$jobsWaiting = Job::where('jobstatus', 'w')->where('jobtype', 'send')->where('approved', 1)->get();
foreach ($jobsWaiting as $job) {
$this->dispatch(new SendEmail($job->id));
}
$x = 1;
while ($x <= count($jobsWaiting)) {
exec("php artisan queue:work --daemon");
$x++;
}
}
This is the method that runs at cron, but not work :(