Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if logger exists #299

Merged
merged 2 commits into from Dec 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/enqueue/Consumption/Extension/SignalExtension.php
Expand Up @@ -18,7 +18,7 @@ class SignalExtension implements ExtensionInterface
protected $interruptConsumption = false;

/**
* @var LoggerInterface
* @var LoggerInterface|null
*/
protected $logger;

Expand Down Expand Up @@ -84,7 +84,10 @@ public function onIdle(Context $context)
public function interruptExecutionIfNeeded(Context $context)
{
if (false == $context->isExecutionInterrupted() && $this->interruptConsumption) {
$this->logger->debug('[SignalExtension] Interrupt execution');
if ($this->logger) {
$this->logger->debug('[SignalExtension] Interrupt execution');
}

$context->setExecutionInterrupted($this->interruptConsumption);

$this->interruptConsumption = false;
Expand All @@ -104,7 +107,10 @@ public function handleSignal($signal)
case SIGTERM: // 15 : supervisor default stop
case SIGQUIT: // 3 : kill -s QUIT
case SIGINT: // 2 : ctrl+c
$this->logger->debug('[SignalExtension] Interrupt consumption');
if ($this->logger) {
$this->logger->debug('[SignalExtension] Interrupt consumption');
}

$this->interruptConsumption = true;
break;
default:
Expand Down