Skip to content

Commit

Permalink
Let worker ungracefully exit on memoryExceeded (#17302)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeofguenter authored and taylorotwell committed Jan 12, 2017
1 parent 3b866cd commit a0f9607
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
// Finally, we will check to see if we have exceeded our memory limits or if
// the queue should restart based on other indications. If so, we'll stop
// this worker and let whatever is "monitoring" it restart the process.
if ($this->memoryExceeded($options->memory) ||
$this->queueShouldRestart($lastRestart)) {
if ($this->memoryExceeded($options->memory)) {
$this->stop(12);
} elseif ($this->queueShouldRestart($lastRestart)) {
$this->stop();
}
}
Expand Down Expand Up @@ -466,13 +467,14 @@ public function memoryExceeded($memoryLimit)
/**
* Stop listening and bail out of the script.
*
* @param int $status
* @return void
*/
public function stop()
public function stop($status = 0)
{
$this->events->fire(new Events\WorkerStopping);

die;
exit($status);
}

/**
Expand Down

1 comment on commit a0f9607

@vitorbari
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is status 12 used here?

Please sign in to comment.