From 69a2967d39268003a124454522556a60f1cc7e41 Mon Sep 17 00:00:00 2001 From: XieBiao Date: Sat, 20 Jan 2018 12:07:37 +0800 Subject: [PATCH] swoole settings --- README.md | 2 +- src/Swoole/Server.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8301ff65..0e798dc6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ composer require "hhxsv5/laravel-s:~1.0" -vvv ```PHP //run in console! -$svrConf = ['ip' => '0.0.0.0', 'port' => 8011]; +$svrConf = ['ip' => '0.0.0.0', 'port' => 8011, 'settings' => [/*swoole settings*/]]; $laravelConf = ['rootPath' => base_path()]; $s = \Hhxsv5\LaravelS\LaravelS::getInstance($svrConf, $laravelConf); $s->run(); diff --git a/src/Swoole/Server.php b/src/Swoole/Server.php index f66c1767..8c892f3f 100644 --- a/src/Swoole/Server.php +++ b/src/Swoole/Server.php @@ -14,13 +14,14 @@ public function __construct(array $svrConf = [], Laravel $laravel) $ip = isset($svrConf['ip']) ? $svrConf['ip'] : '0.0.0.0'; $port = isset($svrConf['port']) ? $svrConf['port'] : 8841; - if (isset($svrConf['ssl_cert_file'], $svrConf['ssl_key_file'])) { + $settings = isset($svrConf['settings']) ? $svrConf['settings'] : []; + + if (isset($settings['ssl_cert_file'], $settings['ssl_key_file'])) { $this->sw = new \swoole_http_server($ip, $port, SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL); } else { $this->sw = new \swoole_http_server($ip, $port, SWOOLE_PROCESS); } - $settings = isset($svrConf['settings']) ? $svrConf['settings'] : []; $this->sw->set($settings); $this->laravel = $laravel;