Skip to content

Commit

Permalink
Refactor working next job for daemon to allow Laravel's timeout handl…
Browse files Browse the repository at this point in the history
…ing to work
  • Loading branch information
Max Brokman committed Sep 6, 2016
1 parent 799b6e9 commit 9328a68
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
* @param \Illuminate\Queue\WorkerOptions $options
* @return void
*/
public function daemon($connectionName, $queue = null, WorkerOptions $options)
public function daemon($connectionName, $queue, WorkerOptions $options)
{
$lastRestart = $this->getTimestampOfLastQueueRestart();

Expand Down Expand Up @@ -120,7 +120,7 @@ protected function runNextJobForDaemon($connectionName, $queue, WorkerOptions $o
$this->assertGoodDatabaseConnection();

try {
$this->daemonPop($connectionName, $queue, $options);
parent::runNextJobForDaemon($connectionName, $queue, $options);
} catch (Exception $e) {
if ($this->exceptions) {
$this->exceptions->report($e);
Expand Down Expand Up @@ -149,9 +149,9 @@ protected function runNextJobForDaemon($connectionName, $queue, WorkerOptions $o
* @param string $connectionName
* @param string $queue
* @param WorkerOptions $options
* @return array
* @return void
*/
private function daemonPop($connectionName, $queue = null, WorkerOptions $options)
public function runNextJob($connectionName, $queue, WorkerOptions $options)
{
$connection = $this->manager->connection($connectionName);

Expand All @@ -161,14 +161,12 @@ private function daemonPop($connectionName, $queue = null, WorkerOptions $option
// then immediately return back out. If there is no job on the queue
// we will "sleep" the worker for the specified number of seconds.
if (!is_null($job)) {
return $this->process(
$this->process(
$this->manager->getName($connectionName), $job, $options
);
}

$this->sleep($options->sleep);

return ['job' => null, 'failed' => false];
}

/**
Expand Down

0 comments on commit 9328a68

Please sign in to comment.