Browse Source

Update ubiquity swoole & workerman (#5234)

* increase worker_num (x2)

* increase worker count (x4)
jcheron 5 years ago
parent
commit
c08b6824d7

+ 14 - 12
frameworks/PHP/ubiquity/.ubiquity/_swoole.php

@@ -1,18 +1,20 @@
 #!/usr/bin/env php
 #!/usr/bin/env php
 <?php
 <?php
 // swoole.php
 // swoole.php
-
-if (! defined ( 'DS' )) {
-	define ( 'DS', DIRECTORY_SEPARATOR );
-	define ( 'ROOT', __DIR__ . \DS .'..'.\DS. 'app' . \DS );
+if (! defined('DS')) {
+	define('DS', DIRECTORY_SEPARATOR);
+	define('ROOT', __DIR__ . \DS . '..' . \DS . 'app' . \DS);
 }
 }
-$config=include ROOT.'config/config.php';
-$sConfig= include __DIR__.\DS.'swoole-config.php';
-$config["sessionName"]=null;
-$address=$sConfig['host'].':'.$sConfig['port'];
-$config ["siteUrl"] = 'http://'.$address;
+$config = include ROOT . 'config/config.php';
+$sConfig = include __DIR__ . \DS . 'swoole-config.php';
+$config["sessionName"] = null;
+$address = $sConfig['host'] . ':' . $sConfig['port'];
+$config["siteUrl"] = 'http://' . $address;
 require ROOT . './../vendor/autoload.php';
 require ROOT . './../vendor/autoload.php';
-$swooleServer=new \Ubiquity\servers\swoole\SwooleServer();
+$swooleServer = new \Ubiquity\servers\swoole\SwooleServer();
 $swooleServer->init($config, __DIR__);
 $swooleServer->init($config, __DIR__);
-require ROOT.'config/swooleServices.php';
-$swooleServer->run($sConfig['host'],$sConfig['port']);
+require ROOT . 'config/swooleServices.php';
+$swooleServer->run($sConfig['host'], $sConfig['port'], [
+	'worker_num' => \swoole_cpu_num() * 2,
+	'reactor_num' => \swoole_cpu_num() * 2
+]);

+ 12 - 13
frameworks/PHP/ubiquity/.ubiquity/_workerman.php

@@ -1,19 +1,18 @@
 #!/usr/bin/env php
 #!/usr/bin/env php
 <?php
 <?php
 // workerman.php
 // workerman.php
-
-if (! defined ( 'DS' )) {
-	define ( 'DS', DIRECTORY_SEPARATOR );
-	define ( 'ROOT', __DIR__ . \DS .'..'.\DS. 'app' . \DS );
+if (! defined('DS')) {
+	define('DS', DIRECTORY_SEPARATOR);
+	define('ROOT', __DIR__ . \DS . '..' . \DS . 'app' . \DS);
 }
 }
-$config=include ROOT.'config/config.php';
-$sConfig= include __DIR__.\DS.'workerman-config.php';
-$config["sessionName"]=null;
-$address=$sConfig['host'].':'.$sConfig['port'];
-$config ["siteUrl"] = 'http://'.$address;
+$config = include ROOT . 'config/config.php';
+$sConfig = include __DIR__ . \DS . 'workerman-config.php';
+$config["sessionName"] = null;
+$address = $sConfig['host'] . ':' . $sConfig['port'];
+$config["siteUrl"] = 'http://' . $address;
 require ROOT . './../vendor/autoload.php';
 require ROOT . './../vendor/autoload.php';
-$workerServer=new \Ubiquity\servers\workerman\WorkermanServer();
+$workerServer = new \Ubiquity\servers\workerman\WorkermanServer();
 $workerServer->init($config, __DIR__);
 $workerServer->init($config, __DIR__);
-$workerServer->setDefaultCount(3);
-require ROOT.'config/workerServices.php';
-$workerServer->run($sConfig['host'],$sConfig['port'],$sConfig['socket']??[]);
+$workerServer->setDefaultCount(4);
+require ROOT . 'config/workerServices.php';
+$workerServer->run($sConfig['host'], $sConfig['port'], $sConfig['socket'] ?? []);