public function restartWorker()
{
if ($this->inReload) {
return;
}
$this->inReload = true;
$this->output->writeln('Restart all worker');
foreach ($this->slaves as &$slave) {
$slave['ready'] = false;
//does not accept new connections
$slave['keepClosed'] = false;
//important to not get 'bootstrap failed' exception, when the bootstrap changes files.
$slave['duringBootstrap'] = false;
$slave['bootstrapFailed'] = 0;
/** @var Connection $connection */
$connection = $slave['connection'];
if ($connection && $connection->isWritable()) {
if ($slave['busy']) {
$slave['closeWhenFree'] = true;
} else {
$connection->close();
}
} else {
$this->newInstance($slave['port']);
}
}
$this->inReload = false;
}