当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::shutdown方法代码示例

本文整理汇总了PHP中React\Socket\Server::shutdown方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::shutdown方法的具体用法?PHP Server::shutdown怎么用?PHP Server::shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在React\Socket\Server的用法示例。


在下文中一共展示了Server::shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: shutdown

 /**
  * 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;
 }
开发者ID:marcj,项目名称:php-pm,代码行数:33,代码来源:ProcessManager.php

示例2: assertConnection

 public function assertConnection(array $options, $message = null)
 {
     $settings = array_merge(["ip" => "0.0.0.0", "port" => 0, "startServer" => false, "match" => true], $options);
     // optionally starting server
     if ($settings["startServer"]) {
         $serverLoop = EventLoopFactory::create();
         $server = new SocketServer($serverLoop);
         $server->listen($settings["port"]);
     }
     // client setup
     $clientLoop = EventLoopFactory::create();
     $dnsResolverFactory = new DnsResolverFactory();
     $dns = $dnsResolverFactory->createCached("8.8.8.8", $clientLoop);
     // dunno why dns is required for this shit
     $connector = new SocketConnector($clientLoop, $dns);
     $promise = $connector->create($settings["ip"], $settings["port"])->then(function (SocketStream $stream) {
         $stream->close();
         return true;
     }, function (SocketConnectionException $e) {
         return false;
     });
     $clientLoop->run();
     // catching the output
     $out = null;
     $promise->done(function ($v) use(&$out) {
         $out = $v;
     });
     // optionally cleaning up the server
     if ($settings["startServer"]) {
         $server->shutdown();
     }
     $this->assertEquals($out, $settings["match"], $message);
 }
开发者ID:ihsw,项目名称:toxiproxy-php-client,代码行数:33,代码来源:AbstractTest.php

示例3: checkSigterm

 /**
  * Checks if the SIGTERM is presente in the server.
  */
 protected function checkSigterm()
 {
     if ($this->sigterm) {
         $this->loop->stop();
         $this->socket->shutdown();
         $this->output->writeln('The Foreman Processor has been stopped.');
     }
 }
开发者ID:naroga,项目名称:foreman,代码行数:11,代码来源:Processor.php

示例4: handleRouterStop

 public function handleRouterStop(RouterStopEvent $event)
 {
     if ($this->server) {
         $this->server->shutdown();
     }
     foreach ($this->sessions as $k) {
         $this->sessions[$k]->shutdown();
     }
 }
开发者ID:voryx,项目名称:thruway,代码行数:9,代码来源:RawSocketTransportProvider.php

示例5: closure

 /**
  * @param Server        $server
  * @param LoopInterface $loop
  */
 protected function closure(Server $server, LoopInterface $loop)
 {
     $this->logger->notice('Stopping server ...');
     foreach ($this->serverPushHandlerRegistry->getPushers() as $handler) {
         $handler->close();
         $this->logger->info(sprintf('Stop %s push handler', $handler->getName()));
     }
     $server->emit('end');
     $server->shutdown();
     foreach ($this->periodicRegistry->getPeriodics() as $periodic) {
         if ($periodic instanceof TimerInterface && $loop->isTimerActive($periodic)) {
             $loop->cancelTimer($periodic);
         }
     }
     $loop->stop();
     $this->logger->notice('Server stopped !');
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:21,代码来源:StartServerListener.php

示例6: connectionToTcpServerShouldSucceed

 /** @test */
 public function connectionToTcpServerShouldSucceed()
 {
     $capturedStream = null;
     $loop = new StreamSelectLoop();
     $server = new Server($loop);
     $server->on('connection', $this->expectCallableOnce());
     $server->on('connection', function () use($server, $loop) {
         $server->shutdown();
     });
     $server->listen(9999);
     $connector = new TcpConnector($loop);
     $connector->create('127.0.0.1', 9999)->then(function ($stream) use(&$capturedStream) {
         $capturedStream = $stream;
         $stream->end();
     });
     $loop->run();
     $this->assertInstanceOf('React\\Stream\\Stream', $capturedStream);
 }
开发者ID:gai00,项目名称:socket-client,代码行数:19,代码来源:TcpConnectorTest.php

示例7: shutdown

 /**
  * Shuts down the event loop. This basically exits the process.
  */
 public function shutdown()
 {
     if ($this->inShutdown) {
         return;
     }
     $this->inShutdown = true;
     $this->sendCurrentFiles();
     $this->loop->tick();
     if ($this->connection && $this->connection->isWritable()) {
         $this->connection->close();
     }
     if ($this->server) {
         @$this->server->shutdown();
     }
     if ($this->loop) {
         $this->loop->tick();
         @$this->loop->stop();
     }
     exit;
 }
开发者ID:marcj,项目名称:php-pm,代码行数:23,代码来源:ProcessSlave.php

示例8: testConnect

 public function testConnect()
 {
     $loop = new StreamSelectLoop();
     $deferred = new Deferred();
     $deferred->promise()->then(function ($value) use($loop) {
         $this->assertEquals(1, $value);
         $loop->stop();
     }, function () {
         $this->fail('Promise was rejected');
     });
     $server = new Server($loop);
     $server->listen(54321, '0.0.0.0');
     $server->on('connection', function (Stream $stream) use($deferred, $server) {
         $deferred->resolve(1);
         $server->shutdown();
     });
     $request = new RequestFactory();
     $connector = new TcpConnector($loop);
     $client = new Client($connector, $request);
     $client->connect('127.0.0.1', 54321);
     $loop->run();
 }
开发者ID:afk11,项目名称:stratum-php,代码行数:22,代码来源:ClientTest.php

示例9: quit

 /**
  * Quit the server.
  */
 public function quit()
 {
     $this->logger->info("Quitting server");
     $this->socket->shutdown();
 }
开发者ID:tsufeki,项目名称:phpcmplr,代码行数:8,代码来源:Server.php

示例10: testReturnsResponse

 public function testReturnsResponse()
 {
     $loop = new StreamSelectLoop();
     $request = new RequestFactory();
     $server = new Server($loop);
     $server->on('connection', function (SocketConnection $connection) use($server, $request) {
         $connection->on('data', function ($data) use($connection, $request) {
             $req = $request->response($data);
             $response = new Response($req->getId(), ['1.0']);
             $connection->write($response->write());
         });
         $connection->on('close', function () use($server) {
             $server->shutdown();
         });
     });
     $server->listen(54323, '127.0.0.1');
     $tcp = new TcpConnector($loop);
     $client = new Client($tcp, $request);
     $client->connect('127.0.0.1', 54323)->then(function (Connection $connection) use($loop) {
         $deferred = new Deferred();
         $deferred->promise()->then(function ($value) {
             $this->assertEquals(1, $value);
         });
         $electrum = new ElectrumClient($connection);
         $electrum->getServerVersion('1.9.6', ' 0.6')->then(function () use($deferred, $connection) {
             $deferred->resolve(1);
             $connection->close();
         }, function () use($loop) {
             $loop->stop();
             $this->fail();
         });
     });
     $loop->run();
 }
开发者ID:afk11,项目名称:stratum-php,代码行数:34,代码来源:ConnectionTest.php

示例11: stop

 public function stop()
 {
     $this->socketServer->shutdown();
     parent::stop();
 }
开发者ID:marviktintor,项目名称:pos-1,代码行数:5,代码来源:RestServer.php

示例12: Server

    {
        $ui = Ui::printStatus($this->game);
        $this->connection->write($ui);
        echo $ui;
    }
}
$loop = Factory::create();
$socket = new Server($loop);
$players = [];
$socket->on('connection', function (Connection $conn) use(&$players, $socket) {
    if (count($players) < 2) {
        $players[] = new PlayerConnection($conn);
    }
    if (count($players) == 2) {
        $deferred = new Deferred();
        $deferred->promise()->then(function ($results) use(&$players, $socket) {
            foreach ($results as $result) {
                foreach ($players as $player) {
                    if ($player === $result[0]) {
                        $player->getConnection()->end('You ' . $result[1] . PHP_EOL);
                    }
                }
            }
            $socket->shutdown();
        });
        $game = new Game($players[0], $players[1]);
        $game->start($deferred);
    }
});
$socket->listen(1337, '0.0.0.0');
$loop->run();
开发者ID:phpCedu,项目名称:ReactExamples,代码行数:31,代码来源:ttt_server.php

示例13: close

 /**
  * Shut down the server
  */
 public function close()
 {
     $this->server->shutdown();
 }
开发者ID:tokenly,项目名称:bitcoin-p2p-php,代码行数:7,代码来源:Listener.php

示例14: onClose

 /**
  * @inheritDoc
  */
 public function onClose($reason)
 {
     $this->socket->shutdown();
     parent::onClose($reason);
 }
开发者ID:nepda,项目名称:WampPost,代码行数:8,代码来源:WampPost.php

示例15: shutdown

 /**
  * Stop listening
  */
 public function shutdown()
 {
     $this->io->shutdown();
     $this->observable->notifyCompleted();
 }
开发者ID:domraider,项目名称:rxnet,代码行数:8,代码来源:Httpd.php


注:本文中的React\Socket\Server::shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。