/**
* Handles termination signals, so we can gracefully stop all servers.
*/
public function shutdown()
{
if ($this->inShutdown) {
return;
}
$this->inShutdown = true;
//this method is also called during startup when something crashed, so
//make sure we don't operate on nulls.
$this->output->writeln('<error>Termination received, exiting.</error>');
if ($this->controller) {
@$this->controller->shutdown();
}
if ($this->web) {
@$this->web->shutdown();
}
if ($this->loop) {
$this->loop->tick();
$this->loop->stop();
}
foreach ($this->slaves as $slave) {
if (is_resource($slave['process'])) {
proc_terminate($slave['process']);
}
if ($slave['pid']) {
//make sure its dead
posix_kill($slave['pid'], SIGKILL);
}
}
exit;
}