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/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. 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(); } /** diff --git a/src/Jobs/AsyncJob.php b/src/Jobs/AsyncJob.php index 1379003..5804a99 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. *