Skip to content

Commit 7671d05

Browse files
committed
Properly log error events emitted by the slave HttpServer
1 parent 0eb0a14 commit 7671d05

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/ProcessManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,10 @@ protected function newSlaveInstance($port)
12951295
'data',
12961296
function ($data) use ($port) {
12971297
if ($this->lastWorkerErrorPrintBy !== $port) {
1298-
$this->output->writeln("<info>--- Worker $port stderr ---</info>");
1298+
$this->output->writeln(sprintf('<info>--- Worker %u stderr ---</info>', $port));
12991299
$this->lastWorkerErrorPrintBy = $port;
13001300
}
1301-
$this->output->write("<error>$data</error>");
1301+
$this->output->writeln(sprintf('<error>%s</error>', trim($data)));
13021302
}
13031303
);
13041304
}

src/ProcessSlave.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ function ($controller) {
336336
}
337337

338338
$httpServer->listen($this->server);
339+
if ($this->isLogging()) {
340+
$httpServer->on('error', function (\Exception $e) {
341+
error_log(sprintf('Worker error while processing the request. %s: %s', get_class($e), $e->getMessage()));
342+
});
343+
}
339344

340345
$this->sendMessage($this->controller, 'register', ['pid' => getmypid(), 'port' => $port]);
341346
}

0 commit comments

Comments
 (0)