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. *