Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ class JobCommandController extends CommandController
* Work on a queue and execute jobs
*
* @param string $queueName The name of the queue
* @param integer $limit The max number of jobs that should execute before exiting.
* @return void
*/
public function workCommand($queueName)
public function workCommand($queueName, $limit = 0)
{
$runInfiniteJobs = ($limit === 0 || $limit < 0);
$jobsDone = 0;
do {
try {
$jobsDone++;
$this->jobManager->waitAndExecute($queueName);
} catch (JobQueueException $exception) {
$this->outputLine($exception->getMessage());
Expand All @@ -53,7 +57,7 @@ public function workCommand($queueName)
} catch (\Exception $exception) {
$this->outputLine('Unexpected exception during job execution: %s', array($exception->getMessage()));
}
} while (true);
} while ($runInfiniteJobs || $jobsDone < $limit);
}

/**
Expand Down