コード例 #1
0
ファイル: Server.php プロジェクト: praswicaksono/Vinnige
 /**
  * @param ContainerInterface $app
  */
 public function __construct(ContainerInterface $app)
 {
     $this->app = $app;
     /**
      * create new swoole object
      */
     $this->server = new \swoole_http_server($this->app['Config']['server.hostname'], $this->app['Config']['server.port'], SWOOLE_PROCESS);
     /**
      * set swoole configuration
      */
     $this->server->setGlobal(HTTP_GLOBAL_ALL);
     $this->server->set($this->app['Config']['server.config']);
 }
コード例 #2
0
ファイル: server.php プロジェクト: ddonng/swoole-phalcon
 public function __construct()
 {
     // 创建swoole_http_server对象
     $http = new swoole_http_server("0.0.0.0", 9501);
     // 设置参数
     $http->set(array('worker_num' => 16, 'daemonize' => false, 'max_request' => 10000, 'dispatch_mode' => 1));
     $http->setGlobal(HTTP_GLOBAL_ALL);
     // 绑定WorkerStart
     $http->on('WorkerStart', array($this, 'onWorkerStart'));
     // 绑定request
     $http->on('request', function ($request, $response) {
         ob_start();
         try {
             //注入uri
             $_GET['_url'] = $request->server['request_uri'];
             $application = new \Phalcon\Mvc\Application($this->di);
             echo $application->handle()->getContent();
         } catch (Exception $e) {
             echo $e->getMessage();
         }
         $result = ob_get_contents();
         ob_end_clean();
         $response->end($result);
     });
     $http->start();
 }
コード例 #3
0
 public function __construct()
 {
     // 创建swoole_http_server对象
     $http = new swoole_http_server("0.0.0.0", 9502);
     // 设置参数
     $http->set(array('worker_num' => 16, 'daemonize' => false, 'max_request' => 100000, 'dispatch_mode' => 1));
     $http->setGlobal(HTTP_GLOBAL_ALL);
     // 绑定WorkerStart
     $http->on('WorkerStart', array($this, 'onWorkerStart'));
     // 绑定request
     $http->on('request', array($this, 'onRequest'));
     //开启服务器
     $http->start();
 }
コード例 #4
0
ファイル: Stack.php プロジェクト: praswicaksono/veloce
 /**
  * @param App $app
  * @param array $serverSettings
  */
 public function __construct(App $app, array $serverSettings = [])
 {
     $app->getContainer()['http.server.config'] = $serverSettings;
     $app->getContainer()['swoole.http.server'] = function ($container) {
         $httpServer = new \swoole_http_server($this->host, $this->port);
         $httpServer->set($container['http.server.config']);
         $httpServer->setGlobal(HTTP_GLOBAL_ALL);
         $httpServer->on('request', $container['http.request.handler']);
         return $httpServer;
     };
     $app->getContainer()['http.request.handler'] = function () use($app) {
         return new RequestHandler($app);
     };
     $this->app = $app;
 }
コード例 #5
0
ファイル: HttpServer.php プロジェクト: swordkee/phalcon-demo
 public function __construct()
 {
     $http = new swoole_http_server("0.0.0.0", 9501);
     $http->set(array('worker_num' => 50, 'daemonize' => true, 'max_request' => 10000, 'dispatch_mode' => 16));
     $http->setGlobal(HTTP_GLOBAL_ALL);
     $http->on('Start', function () {
         if (function_exists('cli_set_process_title')) {
             cli_set_process_title('app_server');
         } else {
             if (function_exists('swoole_set_process_name')) {
                 swoole_set_process_name('app_server');
             }
         }
     });
     $http->on('Request', array($this, 'onRequest'));
     $http->start();
 }