From b9ec4b894415b6de32592db66fc5172c5c3da228 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 21 Jan 2015 13:42:23 +0100 Subject: [PATCH 1/4] Add deleted flag Fixes #31, this was not in the AbstractJob in L4.0 --- src/Jobs/AsyncJob.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Jobs/AsyncJob.php b/src/Jobs/AsyncJob.php index 1379003..220111f 100644 --- a/src/Jobs/AsyncJob.php +++ b/src/Jobs/AsyncJob.php @@ -8,6 +8,13 @@ class AsyncJob extends SyncJob { + /** + * Indicates if the job has been deleted. + * + * @var bool + */ + protected $deleted = false; + /** * The job model. * From fa7106170e8a90da585eb89cde00edbb4dbd363c Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 21 Jan 2015 13:43:08 +0100 Subject: [PATCH 2/4] Update AsyncJob.php --- src/Jobs/AsyncJob.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Jobs/AsyncJob.php b/src/Jobs/AsyncJob.php index 220111f..5804a99 100644 --- a/src/Jobs/AsyncJob.php +++ b/src/Jobs/AsyncJob.php @@ -9,12 +9,12 @@ class AsyncJob extends SyncJob { /** - * Indicates if the job has been deleted. - * - * @var bool - */ - protected $deleted = false; - + * Indicates if the job has been deleted. + * + * @var bool + */ + protected $deleted = false; + /** * The job model. * From c3673f77069677c4a116f9393c3077c7f2882c52 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 18 Feb 2015 14:07:44 +0100 Subject: [PATCH 3/4] Use Symfony Process See #30 --- composer.json | 5 +++-- src/AsyncQueue.php | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ddfb668..8e0ef0a 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,9 @@ ], "require": { "php": ">=5.3.0", - "illuminate/support": "4.x|5.0.x", - "illuminate/console": "4.x|5.0.x" + "illuminate/support": "4.x", + "illuminate/console": "4.x", + "symfony/process": "~2.3" }, "autoload": { "classmap": [ diff --git a/src/AsyncQueue.php b/src/AsyncQueue.php index af2b631..75f72cd 100644 --- a/src/AsyncQueue.php +++ b/src/AsyncQueue.php @@ -3,6 +3,7 @@ use Barryvdh\Queue\Models\Job; use Illuminate\Queue\SyncQueue; +use Symfony\Component\Process\Process; class AsyncQueue extends SyncQueue { @@ -68,8 +69,11 @@ public function storeJob($job, $data, $delay = 0) */ public function startProcess($jobId, $delay = 0) { - chdir($this->container['path.base']); - exec($this->getCommand($jobId, $delay)); + $command = $this->getCommand($jobId, $delay); + $cwd = $this->container['path.base']; + + $process = new Process($command, $cwd); + $process->run(); } /** From a1d7ed9cd2a00caf3099e8e6e5e327b36782ed2d Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 18 Feb 2015 14:14:48 +0100 Subject: [PATCH 4/4] Link to 0.4 for L5 --- readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index b68a96a..6a3092a 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,9 @@ -# Laravel 4/5 Async Queue Driver +# Laravel 4 Async Queue Driver ## Push a function/closure to the background. +### For Laravel 5, check the [0.4 branch](https://github.com/barryvdh/laravel-async-queue/tree/0.4) (Work-in-progress) + Just like the 'sync' driver, this is not a real queue driver. It is always fired immediatly. The only difference is that the closure is sent to the background without waiting for the response. This package is more usable as an alternative for running incidental tasks in the background, without setting up a 'real' queue driver.