From 52464ebb510be8806bfd682fb64a7982946d4de5 Mon Sep 17 00:00:00 2001 From: Jairo Correa Date: Sat, 14 May 2016 21:22:49 -0300 Subject: [PATCH] Fix issue #12628 Scheduler no longer runs commands in background --- src/Illuminate/Console/Scheduling/Event.php | 37 ++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Console/Scheduling/Event.php b/src/Illuminate/Console/Scheduling/Event.php index 1e0f21367c26..cb31d02d715d 100644 --- a/src/Illuminate/Console/Scheduling/Event.php +++ b/src/Illuminate/Console/Scheduling/Event.php @@ -63,6 +63,13 @@ class Event */ public $withoutOverlapping = false; + /** + * Indicates if the command should run in background. + * + * @var bool + */ + public $runInBackground = false; + /** * The array of filter callbacks. * @@ -142,7 +149,11 @@ protected function getDefaultOutput() */ public function run(Container $container) { - $this->runCommandInForeground($container); + if (! $this->runInBackground) { + $this->runCommandInForeground($container); + } else { + $this->runCommandInBackground(); + } } /** @@ -162,6 +173,18 @@ protected function runCommandInForeground(Container $container) $this->callAfterCallbacks($container); } + /** + * Run the command in the background. + * + * @return void + */ + protected function runCommandInBackground() + { + (new Process( + $this->buildCommand(), base_path(), null, null, null + ))->run(); + } + /** * Call all of the "before" callbacks for the event. * @@ -637,6 +660,18 @@ public function withoutOverlapping() }); } + /** + * State that the command should run in background. + * + * @return $this + */ + public function runInBackground() + { + $this->runInBackground = true; + + return $this; + } + /** * Register a callback to further filter the schedule. *