Skip to content

Commit e1d2959

Browse files
authored
Merge pull request #299 from pascaldevink/check_if_logger_exists
Check if logger exists
2 parents f8ac4eb + 12475ea commit e1d2959

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Diff for: pkg/enqueue/Consumption/Extension/SignalExtension.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SignalExtension implements ExtensionInterface
1818
protected $interruptConsumption = false;
1919

2020
/**
21-
* @var LoggerInterface
21+
* @var LoggerInterface|null
2222
*/
2323
protected $logger;
2424

@@ -84,7 +84,10 @@ public function onIdle(Context $context)
8484
public function interruptExecutionIfNeeded(Context $context)
8585
{
8686
if (false == $context->isExecutionInterrupted() && $this->interruptConsumption) {
87-
$this->logger->debug('[SignalExtension] Interrupt execution');
87+
if ($this->logger) {
88+
$this->logger->debug('[SignalExtension] Interrupt execution');
89+
}
90+
8891
$context->setExecutionInterrupted($this->interruptConsumption);
8992

9093
$this->interruptConsumption = false;
@@ -104,7 +107,10 @@ public function handleSignal($signal)
104107
case SIGTERM: // 15 : supervisor default stop
105108
case SIGQUIT: // 3 : kill -s QUIT
106109
case SIGINT: // 2 : ctrl+c
107-
$this->logger->debug('[SignalExtension] Interrupt consumption');
110+
if ($this->logger) {
111+
$this->logger->debug('[SignalExtension] Interrupt consumption');
112+
}
113+
108114
$this->interruptConsumption = true;
109115
break;
110116
default:

0 commit comments

Comments
 (0)