public function __construct($bridgeName = null, $appBootstrap, $appenv) { $this->bridgeName = $bridgeName; $this->bootstrap($appBootstrap, $appenv); $this->connectToMaster(); $this->loop->run(); }
public function __construct($bridgeName = null, $appBootstrap, $appenv, $host, $portOffset, $masterPort) { $this->bridgeName = $bridgeName; $this->slaveHost = $host; $this->portOffset = $portOffset; $this->masterPort = $masterPort; $this->bootstrap($appBootstrap, $appenv); $this->connectToMaster(); $this->setTimer(); $this->loop->run(); }
/** * Starts the main loop. Blocks. */ public function run() { Debug::enable(); gc_disable(); //necessary, since connections will be dropped without reasons after several hundred connections. $this->loop = \React\EventLoop\Factory::create(); $this->controller = new \React\Socket\Server($this->loop); $this->controller->on('connection', array($this, 'onSlaveConnection')); $this->controller->listen(5500); $this->web = new \React\Socket\Server($this->loop); $this->web->on('connection', array($this, 'onWeb')); $this->web->listen($this->port, $this->host); $this->tcpConnector = new \React\SocketClient\TcpConnector($this->loop); $pcntl = new \MKraemer\ReactPCNTL\PCNTL($this->loop); $pcntl->on(SIGTERM, [$this, 'shutdown']); $pcntl->on(SIGINT, [$this, 'shutdown']); if ($this->isDebug()) { $this->loop->addPeriodicTimer(0.5, function () { $this->checkChangedFiles(); }); } $this->isRunning = true; $loopClass = (new \ReflectionClass($this->loop))->getShortName(); $this->output->writeln("<info>Starting PHP-PM with {$this->slaveCount} workers, using {$loopClass} ...</info>"); for ($i = 0; $i < $this->slaveCount; $i++) { $this->newInstance(5501 + $i); } $this->loop->run(); }
/** * Starts the main loop. Blocks. */ public function run() { Debug::enable(); //make whatever is necessary to disable all stuff that could buffer output ini_set('zlib.output_compression', 0); ini_set('output_buffering', 0); ini_set('implicit_flush', 1); ob_implicit_flush(1); $this->loop = \React\EventLoop\Factory::create(); $this->controller = new React\Server($this->loop); $this->controller->on('connection', array($this, 'onSlaveConnection')); $this->controllerHost = $this->getNewControllerHost(); $this->controller->listen(5500, $this->controllerHost); $this->web = new \React\Socket\Server($this->loop); $this->web->on('connection', array($this, 'onWeb')); $this->web->listen($this->port, $this->host); $this->tcpConnector = new \React\SocketClient\TcpConnector($this->loop); $pcntl = new \MKraemer\ReactPCNTL\PCNTL($this->loop); $pcntl->on(SIGTERM, [$this, 'shutdown']); $pcntl->on(SIGINT, [$this, 'shutdown']); $pcntl->on(SIGCHLD, [$this, 'handleSigchld']); $pcntl->on(SIGUSR1, [$this, 'restartWorker']); if ($this->isDebug()) { $this->loop->addPeriodicTimer(0.5, function () { $this->checkChangedFiles(); }); } $this->isRunning = true; $loopClass = (new \ReflectionClass($this->loop))->getShortName(); $this->output->writeln("<info>Starting PHP-PM with {$this->slaveCount} workers, using {$loopClass} ...</info>"); for ($i = 0; $i < $this->slaveCount; $i++) { $this->newInstance(5501 + $i); } $this->loop->run(); }
/** * Start the transport */ public function start($startLoop = true) { $this->transportProvider->startTransportProvider($this, $this->loop); if ($startLoop) { $this->loop->run(); } }
/** * Connects to ProcessManager, master process. */ public function run() { $this->loop = \React\EventLoop\Factory::create(); $this->errorLogger = BufferingLogger::create(); ErrorHandler::register(new ErrorHandler($this->errorLogger)); $client = stream_socket_client($this->config['controllerHost']); $this->controller = new \React\Socket\Connection($client, $this->loop); $pcntl = new \MKraemer\ReactPCNTL\PCNTL($this->loop); $pcntl->on(SIGTERM, [$this, 'shutdown']); $pcntl->on(SIGINT, [$this, 'shutdown']); register_shutdown_function([$this, 'shutdown']); $this->bindProcessMessage($this->controller); $this->controller->on('close', \Closure::bind(function () { $this->shutdown(); }, $this)); $this->server = new React\Server($this->loop); //our version for now, because of unix socket support $http = new HttpServer($this->server); $http->on('request', array($this, 'onRequest')); //port is only used for tcp connection. If unix socket, 'host' contains the socket path $port = $this->config['port']; $host = $this->config['host']; while (true) { try { $this->server->listen($port, $host); break; } catch (\React\Socket\ConnectionException $e) { usleep(500); } } $this->sendMessage($this->controller, 'register', ['pid' => getmypid(), 'port' => $port]); $this->loop->run(); }
/** * Connects to ProcessManager, master process. */ public function run() { $this->loop = \React\EventLoop\Factory::create(); ErrorHandler::register(new ErrorHandler(new BufferingLogger())); $this->client = stream_socket_client('tcp://127.0.0.1:5500'); $this->connection = new \React\Socket\Connection($this->client, $this->loop); $this->connection->on('error', function ($data) { var_dump($data); }); $pcntl = new \MKraemer\ReactPCNTL\PCNTL($this->loop); $pcntl->on(SIGTERM, [$this, 'shutdown']); $pcntl->on(SIGINT, [$this, 'shutdown']); register_shutdown_function([$this, 'shutdown']); $this->bindProcessMessage($this->connection); $this->connection->on('close', \Closure::bind(function () { $this->shutdown(); }, $this)); $this->server = new \React\Socket\Server($this->loop); $this->server->on('error', function ($data) { var_dump($data); }); $http = new HttpServer($this->server); $http->on('request', array($this, 'onRequest')); $http->on('error', function ($data) { var_dump($data); }); $port = $this->config['port']; while (true) { try { $this->server->listen($port); break; } catch (\React\Socket\ConnectionException $e) { usleep(500); } } $this->sendMessage($this->connection, 'register', ['pid' => getmypid(), 'port' => $port]); $this->loop->run(); }
/** * */ public function run() { $this->reactLoop->run(); }
function loop() { $this->loop->run(); }
/** * */ public function run() { $this->loop->run(); }
/** * @return Client */ public function run() : Client { $this->loop->run(); return $this; }