public function __construct($conf = array())
 {
     parent::__construct($conf);
     // Connect to each mongrel2 servers on port PUB & Control only
     // The worker do not want to receive HTTP requests from mongrel2
     $servers = Conf::f('server_conf', null);
     if ($servers === null) {
         Log::fatal("No mongrel2 servers in the configuration");
         Log::flush();
         exit(0);
     }
     foreach ($servers as $serverId => $server) {
         // Ignore servers without control port
         if (isset($server['ctrl_addr']) === false || $server['ctrl_addr'] === null || isset($server['pub_addr']) === false || $server['pub_addr'] === null) {
             continue;
         }
         Log::info('Server #' . $serverId . ' Control = ' . $server['ctrl_addr'] . '    Pub = ' . $server['pub_addr']);
         $connection = new Connection(null, $server['pub_addr'], $server['ctrl_addr']);
         $connection->connect();
         $this->connections[] = $connection;
         $this->jobs[] = array();
     }
     if (count($this->connections) === 0) {
         Log::fatal('No mongrel2 servers with control port detected');
         Log::flush();
         exit(0);
     }
     Log::info('Task ready, ' . gmdate('c'));
 }
Exemple #2
0
 public function testSendIterable()
 {
     $this->markTestIncomplete('To rewrite');
     $iter = array('a', 'b');
     $socket = new DummyZMQSocket();
     $socket->setNextRecv(file_get_contents(__DIR__ . '/../data/example.payload'));
     $conn = new mongrel2\Connection($socket, $socket);
     $mess = $conn->recv();
     $res = new http\Response($iter);
     $res->sendIterable($mess, $conn);
     $res->sendIterable($mess, $conn, false);
 }
Exemple #3
0
 public function testReplyResponse()
 {
     $this->markTestIncomplete('To rewrite');
     $response = new DummyResponse();
     $socket_pull = new DummyZMQSocket();
     $socket_pub = new DummyZMQSocket();
     $conn = new mongrel2\Connection($socket_pull, $socket_pub);
     $mess = '34f9ceee-cd52-4b7f-b197-88bf2f0ec378 6 /handlertest/foo 422:{"PATH":"/handlertest/foo","user-agent":"curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15","host":"localhost:6767","accept":"*/*","content-type":"multipart/form-data; boundary=----------------------------b9069e918c9e","x-forwarded-for":"::1","content-length":"21894","METHOD":"JSON","VERSION":"HTTP/1.1","URI":"/handlertest/foo?toto=titi","QUERY":"toto=titi","PATTERN":"/handlertest"},7:"HELLO"';
     $conn->replyResponse($mess, $response);
     $this->assertEquals(false, false);
 }