Skip to content

Commit

Permalink
Added error checking into DaemonFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Carter committed Aug 14, 2015
1 parent 1ba8caa commit cc365ab
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/DaemonFactory.php
Expand Up @@ -19,6 +19,10 @@ public function createDaemon($kernel)
{
$socket = fopen('php://fd/'.DaemonInterface::FCGI_LISTENSOCK_FILENO, 'r');

if (false === $socket) {
throw new \RuntimeException('Could not open FCGI_LISTENSOCK_FILENO');
}

return $this->createDaemonFromStreamSocket($kernel, $socket);
}

Expand All @@ -29,7 +33,12 @@ public function createDaemon($kernel)
*/
public function createTcpDaemon($kernel, $port, $host = 'localhost')
{
$socket = stream_socket_server('tcp://'.$host.':'.$port);
$address = 'tcp://'.$host.':'.$port;
$socket = stream_socket_server($address);

if (false === $socket) {
throw new \RuntimeException('Could not create stream socket server on: '.$address);
}

return $this->createDaemonFromStreamSocket($kernel, $socket);
}
Expand Down

0 comments on commit cc365ab

Please sign in to comment.