Skip to content

Commit

Permalink
Fix issue laravel#12628 Scheduler no longer runs commands in background
Browse files Browse the repository at this point in the history
  • Loading branch information
jn-jairo committed May 15, 2016
1 parent 5fa3e4e commit 52464eb
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -142,7 +149,11 @@ protected function getDefaultOutput()
*/
public function run(Container $container)
{
$this->runCommandInForeground($container);
if (! $this->runInBackground) {
$this->runCommandInForeground($container);
} else {
$this->runCommandInBackground();
}
}

/**
Expand All @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 52464eb

Please sign in to comment.