public function onSlaveConnection(Connection $conn)
{
$this->bindProcessMessage($conn);
$conn->on('close', \Closure::bind(function () use($conn) {
if ($this->inShutdown) {
return;
}
if (!$this->isConnectionRegistered($conn)) {
// this connection is not registered, so it died during the ProcessSlave constructor.
$this->output->writeln('<error>Worker permanent closed during PHP-PM bootstrap. Not so cool. ' . 'Not your fault, please create a ticket at github.com/php-pm/php-pm with' . 'the output of `ppm start -vv`.</error>');
return;
}
$port = $this->getPort($conn);
$slave =& $this->slaves[$port];
if ($this->output->isVeryVerbose()) {
$this->output->writeln(sprintf('Worker #%d closed after %d handled requests', $slave['port'], $slave['requests']));
}
$slave['ready'] = false;
if (isset($slave['stderr'])) {
$slave['stderr']->close();
}
if (is_resource($slave['process'])) {
proc_terminate($slave['process'], SIGKILL);
}
posix_kill($slave['pid'], SIGKILL);
//make sure its really dead
if ($slave['duringBootstrap']) {
$this->bootstrapFailed($conn);
}
$this->newInstance($slave['port']);
}, $this));
}