Browse Source

Ubiquity refactoring (#5916)

* remove ubiquity-swoole-mysql-async

* add workerman-mysql + refactoring

* update worker-mysql urls

* update Mysql urls

* Update DbMy.php
jcheron 5 years ago
parent
commit
e3a2d6a10e
30 changed files with 284 additions and 251 deletions
  1. 3 16
      frameworks/PHP/ubiquity/app/config/config.php
  2. 6 4
      frameworks/PHP/ubiquity/app/controllers/Cache.php
  3. 10 8
      frameworks/PHP/ubiquity/app/controllers/Db.php
  4. 5 5
      frameworks/PHP/ubiquity/app/controllers/DbMy.php
  5. 14 16
      frameworks/PHP/ubiquity/app/controllers/Db_.php
  6. 4 6
      frameworks/PHP/ubiquity/app/controllers/Fortunes_.php
  7. 0 38
      frameworks/PHP/ubiquity/app/controllers/SwooleDbAsync.php
  8. 0 22
      frameworks/PHP/ubiquity/app/controllers/SwooleFortunesAsync.php
  9. 24 0
      frameworks/PHP/ubiquity/app/controllers/utils/DbAsyncTrait.php
  10. 15 0
      frameworks/PHP/ubiquity/app/controllers/utils/DbTrait.php
  11. 18 0
      frameworks/PHP/ubiquity/app/controllers/utils/FortunesAsyncTrait.php
  12. 31 27
      frameworks/PHP/ubiquity/benchmark_config.json
  13. 17 0
      frameworks/PHP/ubiquity/deploy/conf/roadrunner/mysql/rrServices.php
  14. 6 6
      frameworks/PHP/ubiquity/deploy/conf/roadrunner/pgsql/rrServices.php
  15. 15 0
      frameworks/PHP/ubiquity/deploy/conf/swoole/mysql/swooleServices.php
  16. 6 6
      frameworks/PHP/ubiquity/deploy/conf/swoole/pgsql/swooleServices.php
  17. 30 0
      frameworks/PHP/ubiquity/deploy/conf/ubiquity-config.php
  18. 19 0
      frameworks/PHP/ubiquity/deploy/conf/workerman/mysql/workerServices.php
  19. 11 10
      frameworks/PHP/ubiquity/deploy/conf/workerman/pgsql/workerServices.php
  20. 0 17
      frameworks/PHP/ubiquity/deploy/roadrunner/rrMysqlServices.php
  21. 0 15
      frameworks/PHP/ubiquity/deploy/swoole/swooleMysqlAsyncServices.php
  22. 0 12
      frameworks/PHP/ubiquity/deploy/swoole/swooleMysqlServices.php
  23. 2 2
      frameworks/PHP/ubiquity/ubiquity-roadrunner-mysql.dockerfile
  24. 1 1
      frameworks/PHP/ubiquity/ubiquity-roadrunner.dockerfile
  25. 0 37
      frameworks/PHP/ubiquity/ubiquity-swoole-mysql-async.dockerfile
  26. 1 1
      frameworks/PHP/ubiquity/ubiquity-swoole-mysql.dockerfile
  27. 1 1
      frameworks/PHP/ubiquity/ubiquity-swoole.dockerfile
  28. 40 0
      frameworks/PHP/ubiquity/ubiquity-workerman-mysql.dockerfile
  29. 2 0
      frameworks/PHP/ubiquity/ubiquity-workerman.dockerfile
  30. 3 1
      frameworks/PHP/ubiquity/ubiquity.dockerfile

+ 3 - 16
frameworks/PHP/ubiquity/app/config/config.php

@@ -1,7 +1,7 @@
 <?php
 return array(
 	"database" => [
-		'default' => [
+		'mysql' => [
 			"wrapper" => "\\Ubiquity\\db\\providers\\pdo\\PDOWrapper",
 			"type" => "mysql",
 			"dbName" => "hello_world",
@@ -10,7 +10,7 @@ return array(
 			"user" => "benchmarkdbuser", // benchmarkdbuser
 			"password" => "benchmarkdbpass", // benchmarkdbpass
 			"options" => [
-				\PDO::ATTR_PERSISTENT => true
+				\PDO::ATTR_EMULATE_PREPARES => false
 			],
 			"cache" => false
 		],
@@ -23,7 +23,7 @@ return array(
 			"user" => "benchmarkdbuser", // benchmarkdbuser
 			"password" => "benchmarkdbpass", // benchmarkdbpass
 			"options" => [
-				\PDO::ATTR_PERSISTENT => true
+				\PDO::ATTR_EMULATE_PREPARES => false
 			],
 			"cache" => false
 		],
@@ -35,19 +35,6 @@ return array(
 			"port" => 5432,
 			"user" => "benchmarkdbuser", // benchmarkdbuser
 			"password" => "benchmarkdbpass", // benchmarkdbpass
-			"options" => [
-				\PDO::ATTR_PERSISTENT => false
-			],
-			"cache" => false
-		],
-		'async' => [
-			"wrapper" => "\\Ubiquity\\db\\providers\\swoole\SwooleWrapper",
-			"type" => "mysql",
-			"dbName" => "hello_world",
-			"serverName" => "tfb-database", // tfb-database
-			"port" => 3306,
-			"user" => "benchmarkdbuser", // benchmarkdbuser
-			"password" => "benchmarkdbpass", // benchmarkdbpass
 			"options" => [],
 			"cache" => false
 		]

+ 6 - 4
frameworks/PHP/ubiquity/app/controllers/Cache.php

@@ -1,28 +1,30 @@
 <?php
 namespace controllers;
 
+use controllers\utils\DbTrait;
 
 /**
  * Bench controller.
  */
 class Cache extends \Ubiquity\controllers\Controller {
+	use DbTrait;
 
 	protected $cache;
 
 	public function __construct() {
-		$this->cache=\Ubiquity\orm\DAO::getCache();
+		$this->cache = \Ubiquity\orm\DAO::getCache();
 	}
 
 	public function initialize() {
 		\Ubiquity\utils\http\UResponse::setContentType('application/json');
 	}
 
-	public function index(){}
+	public function index() {}
 
 	public function cachedquery($queries = 1) {
 		$worlds = [];
-		$queries = \min(\max($queries, 1), 500);
-		for ($i = 0; $i < $queries; ++ $i) {
+		$count = $this->getCount($queries);
+		while ($count --) {
 			$worlds[] = ($this->cache->fetch('models\\CachedWorld', \mt_rand(1, 10000)))->_rest;
 		}
 		echo \json_encode($worlds);

+ 10 - 8
frameworks/PHP/ubiquity/app/controllers/Db.php

@@ -3,11 +3,13 @@ namespace controllers;
 
 use Ubiquity\orm\SDAO;
 use models\World;
+use controllers\utils\DbTrait;
 
 /**
  * Bench controller.
  */
 class Db extends \Ubiquity\controllers\Controller {
+	use DbTrait;
 
 	public function __construct() {}
 
@@ -19,16 +21,16 @@ class Db extends \Ubiquity\controllers\Controller {
 	public function index() {
 		echo \json_encode((SDAO::getById(World::class, [
 			'id' => \mt_rand(1, 10000)
-		]))->_rest);
+		], false))->_rest);
 	}
 
 	public function query($queries = 1) {
 		$worlds = [];
-		$queries = \min(\max($queries, 1), 500);
-		for ($i = 0; $i < $queries; ++ $i) {
+		$count = $this->getCount($queries);
+		for ($i = 0; $i < $count; ++ $i) {
 			$worlds[] = (SDAO::getById(World::class, [
 				'id' => \mt_rand(1, 10000)
-			]))->_rest;
+			], false))->_rest;
 		}
 		echo \json_encode($worlds);
 	}
@@ -36,17 +38,17 @@ class Db extends \Ubiquity\controllers\Controller {
 	public function update($queries = 1) {
 		$worlds = [];
 
-		$queries = \min(\max($queries, 1), 500);
-		$ids = $this->getUniqueRandomNumbers($queries);
+		$count = $this->getCount($queries);
+		$ids = $this->getUniqueRandomNumbers($count);
 		foreach ($ids as $id) {
 			$world = SDAO::getById(World::class, [
 				'id' => $id
-			]);
+			], false);
 			$world->randomNumber = \mt_rand(1, 10000);
 			SDAO::toUpdate($world);
 			$worlds[] = $world->_rest;
 		}
-		SDAO::updateGroups($queries);
+		SDAO::updateGroups($count);
 
 		echo \json_encode($worlds);
 	}

+ 5 - 5
frameworks/PHP/ubiquity/app/controllers/DbMy.php

@@ -6,21 +6,21 @@ use Ubiquity\orm\DAO;
 /**
  * Bench controller.
  */
-class DbMy extends DbPg {
+class DbMy extends Db_ {
 
 	public function update($queries = 1) {
 		$worlds = [];
-		$queries = \min(\max($queries, 1), 500);
-		$ids = $this->getUniqueRandomNumbers($queries);
+		$count = $this->getCount($queries);
+		$ids = $this->getUniqueRandomNumbers($count);
 		foreach ($ids as $id) {
-			$world = DAO::executePrepared('world', [
+			$world = self::$pDao->execute([
 				'id' => $id
 			]);
 			$world->randomNumber = \mt_rand(1, 10000);
 			DAO::toUpdate($world);
 			$worlds[] = $world->_rest;
 		}
-		DAO::updateGroups($queries);
+		DAO::updateGroups($count);
 		echo \json_encode($worlds);
 	}
 

+ 14 - 16
frameworks/PHP/ubiquity/app/controllers/DbPg.php → frameworks/PHP/ubiquity/app/controllers/Db_.php

@@ -2,30 +2,27 @@
 namespace controllers;
 
 use Ubiquity\orm\DAO;
+use controllers\utils\DbTrait;
+use controllers\utils\DbAsyncTrait;
 
 /**
  * Bench controller.
  */
-class DbPg extends \Ubiquity\controllers\Controller {
-
-	public function __construct() {}
-
-	public function initialize() {
-		\Ubiquity\utils\http\UResponse::setContentType('application/json');
-	}
+class Db_ extends \Ubiquity\controllers\Controller {
+	use DbTrait,DbAsyncTrait;
 
 	public function index() {
-		$world = DAO::executePrepared('world', [
+		echo \json_encode(self::$pDao->execute([
 			'id' => \mt_rand(1, 10000)
-		]);
-		echo \json_encode($world->_rest);
+		])->_rest);
 	}
 
 	public function query($queries = 1) {
 		$worlds = [];
-		$queries = \min(\max($queries, 1), 500);
-		for ($i = 0; $i < $queries; ++ $i) {
-			$worlds[] = (DAO::executePrepared('world', [
+		$count = $this->getCount($queries);
+
+		while ($count --) {
+			$worlds[] = (self::$pDao->execute([
 				'id' => \mt_rand(1, 10000)
 			]))->_rest;
 		}
@@ -34,9 +31,10 @@ class DbPg extends \Ubiquity\controllers\Controller {
 
 	public function update($queries = 1) {
 		$worlds = [];
-		$queries = \min(\max($queries, 1), 500);
-		for ($i = 0; $i < $queries; ++ $i) {
-			$world = DAO::executePrepared('world', [
+		$count = $this->getCount($queries);
+
+		while ($count --) {
+			$world = self::$pDao->execute([
 				'id' => \mt_rand(1, 10000)
 			]);
 			$world->randomNumber = \mt_rand(1, 10000);

+ 4 - 6
frameworks/PHP/ubiquity/app/controllers/Fortunes_.php

@@ -2,16 +2,14 @@
 namespace controllers;
 
 use models\Fortune;
+use controllers\utils\FortunesAsyncTrait;
 
 class Fortunes_ extends \Ubiquity\controllers\SimpleViewAsyncController {
-
-	public function initialize() {
-		\Ubiquity\utils\http\UResponse::setContentType('text/html', 'utf-8');
-	}
+	use FortunesAsyncTrait;
 
 	public function index() {
-		$fortunes = \Ubiquity\orm\DAO::executePrepared('fortune');
-		$fortunes[] = new Fortune(0, 'Additional fortune added at request time.');
+		$fortunes = self::$pDao->execute();
+		$fortunes[0] = new Fortune(0, 'Additional fortune added at request time.');
 		\usort($fortunes, function ($left, $right) {
 			return $left->message <=> $right->message;
 		});

+ 0 - 38
frameworks/PHP/ubiquity/app/controllers/SwooleDbAsync.php

@@ -1,38 +0,0 @@
-<?php
-namespace controllers;
-
-use Ubiquity\orm\DAO;
-
-/**
- * Bench controller.
- */
-class SwooleDbAsync extends \Ubiquity\controllers\Controller {
-
-	public function initialize() {
-		\Ubiquity\utils\http\UResponse::setContentType('application/json');
-	}
-
-	public function index() {
-		$dbInstance = DAO::pool('async');
-
-		$world = DAO::executePrepared('world', [
-			'id' => \mt_rand(1, 10000)
-		]);
-		DAO::freePool($dbInstance);
-		echo \json_encode($world->_rest);
-	}
-
-	public function query($queries = 1) {
-		$queries = \min(\max($queries, 1), 500);
-		$worlds = [];
-		$dbInstance = DAO::pool('async');
-		for ($i = 0; $i < $queries; ++ $i) {
-			$worlds[] = (DAO::executePrepared('world', [
-				'id' => \mt_rand(1, 10000)
-			]))->_rest;
-		}
-		DAO::freePool($dbInstance);
-
-		echo \json_encode($worlds);
-	}
-}

+ 0 - 22
frameworks/PHP/ubiquity/app/controllers/SwooleFortunesAsync.php

@@ -1,22 +0,0 @@
-<?php
-namespace controllers;
-
-use Ubiquity\orm\DAO;
-use models\Fortune;
-
-class SwooleFortunesAsync extends \Ubiquity\controllers\SimpleViewAsyncController {
-
-	public function index() {
-		$dbInstance = DAO::pool('async');
-		$fortunes = DAO::executePrepared('fortune');
-		DAO::freePool($dbInstance);
-		$fortunes[] = (new Fortune())->setId(0)->setMessage('Additional fortune added at request time.');
-		\usort($fortunes, function ($left, $right) {
-			return $left->message <=> $right->message;
-		});
-		$this->loadView('Fortunes/index.php', [
-			'fortunes' => $fortunes
-		]);
-	}
-}
-

+ 24 - 0
frameworks/PHP/ubiquity/app/controllers/utils/DbAsyncTrait.php

@@ -0,0 +1,24 @@
+<?php
+namespace controllers\utils;
+
+use Ubiquity\orm\core\prepared\DAOPreparedQueryById;
+
+trait DbAsyncTrait {
+
+	/**
+	 *
+	 * @var DAOPreparedQueryById
+	 */
+	protected static $pDao;
+
+	public function __construct() {}
+
+	public function initialize() {
+		\Ubiquity\utils\http\UResponse::setContentType('application/json');
+	}
+
+	public static function warmup() {
+		self::$pDao = new DAOPreparedQueryById('models\\World');
+	}
+}
+

+ 15 - 0
frameworks/PHP/ubiquity/app/controllers/utils/DbTrait.php

@@ -0,0 +1,15 @@
+<?php
+namespace controllers\utils;
+
+trait DbTrait {
+
+	public function getCount($queries) {
+		$count = 1;
+		if ($queries > 1) {
+			if (($count = $queries) > 500) {
+				$count = 500;
+			}
+		}
+		return $count;
+	}
+}

+ 18 - 0
frameworks/PHP/ubiquity/app/controllers/utils/FortunesAsyncTrait.php

@@ -0,0 +1,18 @@
+<?php
+namespace controllers\utils;
+
+use Ubiquity\orm\core\prepared\DAOPreparedQueryAll;
+
+trait FortunesAsyncTrait {
+
+	protected static $pDao;
+
+	public static function warmup() {
+		self::$pDao = new DAOPreparedQueryAll('models\\Fortune');
+	}
+
+	public function initialize() {
+		\Ubiquity\utils\http\UResponse::setContentType('text/html', 'utf-8');
+	}
+}
+

+ 31 - 27
frameworks/PHP/ubiquity/benchmark_config.json

@@ -28,10 +28,10 @@
       "workerman": {
         "json_url": "/Json_",
         "plaintext_url": "/Plaintext_",
-        "db_url": "/DbPg",
-        "query_url": "/DbPg/query/",
+        "db_url": "/Db_",
+        "query_url": "/Db_/query/",
         "fortune_url": "/Fortunes_",
-        "update_url": "/DbPg/update/",
+        "update_url": "/Db_/update/",
         "cached_query_url": "/Cache/cachedquery/",
         "port": 8080,
         "approach": "Realistic",
@@ -52,9 +52,9 @@
       "swoole": {
         "json_url": "/Json_",
         "plaintext_url": "/Plaintext_",
-        "db_url": "/DbPg",
-        "update_url": "/DbPg/update/",
-        "query_url": "/DbPg/query/",
+        "db_url": "/Db_",
+        "update_url": "/Db_/update/",
+        "query_url": "/Db_/query/",
         "fortune_url": "/Fortunes_",
         "port": 8080,
         "approach": "Realistic",
@@ -73,6 +73,9 @@
         "versus": "swoole"
       },
       "swoole-mysql": {
+        "db_url": "/DbMy",
+        "query_url": "/DbMy/query/",
+        "fortune_url": "/Fortunes_",
         "update_url": "/DbMy/update/",
         "port": 8080,
         "approach": "Realistic",
@@ -86,41 +89,42 @@
         "webserver": "none",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ubiquity-swoole-mysql-pdo",
+        "display_name": "ubiquity-swoole-mysql",
         "notes": "",
         "versus": "swoole"
       },
-      "swoole-mysql-async": {
-        "db_url": "/SwooleDbAsync",
-        "query_url": "/SwooleDbAsync/query/",
-        "fortune_url": "/SwooleFortunesAsync",
+      "roadrunner": {
+        "json_url": "/Json_",
+        "plaintext_url": "/Plaintext_",
+        "db_url": "/Db_",
+        "query_url": "/Db_/query/",
+        "fortune_url": "/Fortunes_",
+        "update_url": "/Db_/update/",
         "port": 8080,
         "approach": "Realistic",
         "classification": "Fullstack",
-        "database": "MYSQL",
-        "framework": "ubiquity",
+        "database": "Postgres",
+        "framework": "Ubiquity",
         "language": "PHP",
         "flavor": "PHP7",
         "orm": "Full",
-        "platform": "swoole",
+        "platform": "RoadRunner",
         "webserver": "none",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ubiquity-swoole-mysql",
+        "display_name": "ubiquity-roadrunner",
         "notes": "",
-        "versus": "swoole"
+        "versus": "php"
       },
-      "roadrunner": {
-        "json_url": "/Json_",
-        "plaintext_url": "/Plaintext_",
-        "db_url": "/DbPg",
-        "query_url": "/DbPg/query/",
+      "roadrunner-mysql": {
+        "db_url": "/DbMy",
+        "query_url": "/DbMy/query/",
         "fortune_url": "/Fortunes_",
-        "update_url": "/DbPg/update/",
+        "update_url": "/DbMy/update/",
         "port": 8080,
         "approach": "Realistic",
         "classification": "Fullstack",
-        "database": "Postgres",
+        "database": "Mysql",
         "framework": "Ubiquity",
         "language": "PHP",
         "flavor": "PHP7",
@@ -129,11 +133,11 @@
         "webserver": "none",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ubiquity-roadrunner",
+        "display_name": "ubiquity-roadrunner-mysql",
         "notes": "",
         "versus": "php"
       },
-      "roadrunner-mysql": {
+      "workerman-mysql": {
         "db_url": "/DbMy",
         "query_url": "/DbMy/query/",
         "fortune_url": "/Fortunes_",
@@ -146,11 +150,11 @@
         "language": "PHP",
         "flavor": "PHP7",
         "orm": "Full",
-        "platform": "RoadRunner",
+        "platform": "workerman",
         "webserver": "none",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "ubiquity-roadrunner-mysql",
+        "display_name": "ubiquity-workerman-mysql",
         "notes": "",
         "versus": "php"
       }

+ 17 - 0
frameworks/PHP/ubiquity/deploy/conf/roadrunner/mysql/rrServices.php

@@ -0,0 +1,17 @@
+<?php
+\Ubiquity\cache\CacheManager::startProd($config);
+
+\Ubiquity\orm\DAO::setModelsDatabases([
+	'models\\World' => 'mysql',
+	'models\\Fortune' => 'mysql'
+]);
+
+\Ubiquity\cache\CacheManager::warmUpControllers([
+	\controllers\DbMy::class,
+	\controllers\Fortunes_::class
+]);
+
+\Ubiquity\orm\DAO::startDatabase($config, 'mysql');
+\controllers\DbMy::warmup();
+\controllers\Fortunes_::warmup();
+

+ 6 - 6
frameworks/PHP/ubiquity/deploy/roadrunner/rrPgsqlServices.php → frameworks/PHP/ubiquity/deploy/conf/roadrunner/pgsql/rrServices.php

@@ -5,12 +5,12 @@
 	'models\\World' => 'pgsql'
 ]);
 \Ubiquity\cache\CacheManager::warmUpControllers([
-	'controllers\\Plaintext_',
-	'controllers\\Json_',
-	'controllers\\DbPg',
-	'controllers\\Fortunes_'
+	\controllers\Plaintext_::class,
+	\controllers\Json_::class,
+	\controllers\Db_::class,
+	\controllers\Fortunes_::class
 ]);
 
 \Ubiquity\orm\DAO::startDatabase($config, 'pgsql');
-\Ubiquity\orm\DAO::prepareGetById('world', 'models\\World');
-\Ubiquity\orm\DAO::prepareGetAll('fortune', 'models\\Fortune');
+\controllers\Db_::warmup();
+\controllers\Fortunes_::warmup();

+ 15 - 0
frameworks/PHP/ubiquity/deploy/conf/swoole/mysql/swooleServices.php

@@ -0,0 +1,15 @@
+<?php
+\Ubiquity\cache\CacheManager::startProd($config);
+\Ubiquity\orm\DAO::setModelsDatabases([
+	'models\\World' => 'mysql',
+	'models\\Fortune' => 'mysql'
+]);
+\Ubiquity\cache\CacheManager::warmUpControllers([
+	\controllers\DbMy::class,
+	\controllers\Fortunes_::class
+]);
+$swooleServer->on('workerStart', function ($srv) use (&$config) {
+	\Ubiquity\orm\DAO::startDatabase($config, 'mysql');
+	\controllers\DbMy::warmup();
+	\controllers\Fortunes_::warmup();
+});

+ 6 - 6
frameworks/PHP/ubiquity/deploy/swoole/swoolePgsqlServices.php → frameworks/PHP/ubiquity/deploy/conf/swoole/pgsql/swooleServices.php

@@ -5,13 +5,13 @@
 	'models\\World' => 'pgsql'
 ]);
 \Ubiquity\cache\CacheManager::warmUpControllers([
-	'controllers\\Plaintext_',
-	'controllers\\Json_',
-	'controllers\\DbPg',
-	'controllers\\Fortunes_'
+	\controllers\Plaintext_::class,
+	\controllers\Json_::class,
+	\controllers\Db_::class,
+	\controllers\Fortunes_::class
 ]);
 $swooleServer->on('workerStart', function ($srv) use (&$config) {
 	\Ubiquity\orm\DAO::startDatabase($config, 'pgsql');
-	\Ubiquity\orm\DAO::prepareGetById('world', 'models\\World');
-	\Ubiquity\orm\DAO::prepareGetAll('fortune', 'models\\Fortune');
+	\controllers\Db_::warmup();
+	\controllers\Fortunes_::warmup();
 });

+ 30 - 0
frameworks/PHP/ubiquity/deploy/conf/ubiquity-config.php

@@ -0,0 +1,30 @@
+<?php
+return array(
+	"database" => [
+		'default' => [
+			"wrapper" => "\\Ubiquity\\db\\providers\\pdo\\PDOWrapper",
+			"type" => "mysql",
+			"dbName" => "hello_world",
+			"serverName" => "tfb-database", // tfb-database
+			"port" => 3306,
+			"user" => "benchmarkdbuser", // benchmarkdbuser
+			"password" => "benchmarkdbpass", // benchmarkdbpass
+			"options" => [
+				\PDO::ATTR_PERSISTENT => true
+			],
+			"cache" => false
+		]
+	],
+	"test" => false,
+	"debug" => false,
+	"cache" => [
+		"directory" => "cache/",
+		"system" => "Ubiquity\\cache\\system\\ArrayCache",
+		"params" => []
+	],
+	"mvcNS" => [
+		"models" => "models",
+		"controllers" => "controllers",
+		"rest" => ""
+	]
+);

+ 19 - 0
frameworks/PHP/ubiquity/deploy/conf/workerman/mysql/workerServices.php

@@ -0,0 +1,19 @@
+<?php
+\Ubiquity\cache\CacheManager::startProd($config);
+
+\Ubiquity\orm\DAO::setModelsDatabases([
+	'models\\Fortune' => 'mysql',
+	'models\\World' => 'mysql'
+]);
+
+\Ubiquity\cache\CacheManager::warmUpControllers([
+	\controllers\DbMy::class,
+	\controllers\Fortunes_::class
+]);
+
+$workerServer->onWorkerStart = function () use ($config) {
+	\Ubiquity\orm\DAO::startDatabase($config, 'mysql');
+	\controllers\DbMy::warmup();
+	\controllers\Fortunes_::warmup();
+};
+

+ 11 - 10
frameworks/PHP/ubiquity/app/config/workerServices.php → frameworks/PHP/ubiquity/deploy/conf/workerman/pgsql/workerServices.php

@@ -3,25 +3,26 @@
 \Ubiquity\orm\DAO::setModelsDatabases([
 	'models\\Fortune' => 'pgsql',
 	'models\\World' => 'pgsql',
-	'models\\CachedWorld'=>'pgsql-cache'
+	'models\\CachedWorld' => 'pgsql-cache'
 ]);
 
 \Ubiquity\orm\DAO::setCache(new \Ubiquity\cache\dao\DAOMemoryCache());
 
 echo "Loading worlds\n";
-\Ubiquity\orm\DAO::warmupCache('models\\CachedWorld','',false);
-echo "End Loading worlds\n";
+\Ubiquity\orm\DAO::warmupCache('models\\CachedWorld', '', false);
+echo "End Loading\n";
 
 \Ubiquity\cache\CacheManager::warmUpControllers([
-	'controllers\\Plaintext_',
-	'controllers\\Json_',
-	'controllers\\DbPg',
-	'controllers\\Fortunes_',
-	'controllers\\Cache'
+	\controllers\Plaintext_::class,
+	\controllers\Json_::class,
+	\controllers\Db_::class,
+	\controllers\Fortunes_::class,
+	\controllers\Cache::class
 ]);
+
 $workerServer->onWorkerStart = function () use ($config) {
 	\Ubiquity\orm\DAO::startDatabase($config, 'pgsql');
-	\Ubiquity\orm\DAO::prepareGetById('world', 'models\\World');
-	\Ubiquity\orm\DAO::prepareGetAll('fortune', 'models\\Fortune');
+	\controllers\Db_::warmup();
+	\controllers\Fortunes_::warmup();
 };
 

+ 0 - 17
frameworks/PHP/ubiquity/deploy/roadrunner/rrMysqlServices.php

@@ -1,17 +0,0 @@
-<?php
-\Ubiquity\cache\CacheManager::startProd($config);
-
-\Ubiquity\orm\DAO::setModelsDatabases([
-	'models\\World' => 'default',
-	'models\\Fortune' => 'default'
-]);
-
-\Ubiquity\cache\CacheManager::warmUpControllers([
-	'controllers\\DbMy',
-	'controllers\\Fortunes_'
-]);
-
-\Ubiquity\orm\DAO::startDatabase($config, 'default');
-\Ubiquity\orm\DAO::prepareGetById('world', 'models\\World');
-\Ubiquity\orm\DAO::prepareGetAll('fortune', 'models\\Fortune');
-

+ 0 - 15
frameworks/PHP/ubiquity/deploy/swoole/swooleMysqlAsyncServices.php

@@ -1,15 +0,0 @@
-<?php
-\Ubiquity\cache\CacheManager::startProd($config);
-\Ubiquity\orm\DAO::setModelsDatabases([
-	'models\\Fortune' => 'async',
-	'models\\World' => 'async'
-]);
-\Ubiquity\cache\CacheManager::warmUpControllers([
-	'controllers\\SwooleDbAsync',
-	'controllers\\SwooleFortunesAsync'
-]);
-$swooleServer->on('workerStart', function ($srv) use (&$config) {
-	\Ubiquity\orm\DAO::initPooling($config, 'async', \intdiv(512, $srv->setting['worker_num']));
-	\Ubiquity\orm\DAO::prepareGetById('world', 'models\\World');
-	\Ubiquity\orm\DAO::prepareGetAll('fortune', 'models\\Fortune');
-});

+ 0 - 12
frameworks/PHP/ubiquity/deploy/swoole/swooleMysqlServices.php

@@ -1,12 +0,0 @@
-<?php
-\Ubiquity\cache\CacheManager::startProd($config);
-\Ubiquity\orm\DAO::setModelsDatabases([
-	'models\\World' => 'default'
-]);
-\Ubiquity\cache\CacheManager::warmUpControllers([
-	'controllers\\DbMy'
-]);
-$swooleServer->on('workerStart', function ($srv) use (&$config) {
-	\Ubiquity\orm\DAO::startDatabase($config, 'default');
-	\Ubiquity\orm\DAO::prepareGetById('world', 'models\\World');
-});

+ 2 - 2
frameworks/PHP/ubiquity/ubiquity-roadrunner-mysql.dockerfile

@@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive
 RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
 RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq php7.4 php7.4-common php7.4-cgi php7.4-pgsql php-curl php7.4-mysql > /dev/null
+    apt-get install -yqq php7.4 php7.4-common php7.4-cgi php-curl php7.4-mysql > /dev/null
 
 RUN apt-get install -yqq composer > /dev/null
 
@@ -39,6 +39,6 @@ RUN chmod 777 -R /ubiquity/.ubiquity/*
 
 #RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/cgi/php.ini
 
-COPY deploy/roadrunner/rrMysqlServices.php app/config/rrServices.php
+COPY deploy/conf/roadrunner/mysql/rrServices.php app/config/rrServices.php
 
 CMD envwrapper.sh /ubiquity/rr serve

+ 1 - 1
frameworks/PHP/ubiquity/ubiquity-roadrunner.dockerfile

@@ -41,6 +41,6 @@ RUN chmod 777 -R /ubiquity/.ubiquity/*
 
 #RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/cgi/php.ini
 
-COPY deploy/roadrunner/rrPgsqlServices.php app/config/rrServices.php
+COPY deploy/conf/roadrunner/pgsql/rrServices.php app/config/rrServices.php
 
 CMD envwrapper.sh /ubiquity/rr serve

+ 0 - 37
frameworks/PHP/ubiquity/ubiquity-swoole-mysql-async.dockerfile

@@ -1,37 +0,0 @@
-FROM php:7.4
-
-RUN apt-get update > /dev/null
-
-RUN pecl install swoole > /dev/null && \
-    docker-php-ext-enable swoole
-
-RUN docker-php-ext-install pdo_mysql pcntl > /dev/null
-
-COPY deploy/conf/php-async.ini /usr/local/etc/php/php.ini
-RUN echo "zend_extension=opcache.so" >> /usr/local/etc/php/php.ini
-
-ADD ./ /ubiquity
-WORKDIR /ubiquity
-
-RUN chmod -R 777 /ubiquity
-
-RUN ["chmod", "+x", "deploy/run/install-composer.sh"]
-
-RUN deploy/run/install-composer.sh
-
-RUN apt-get update -yqq > /dev/null && \
-    apt-get install -yqq git unzip > /dev/null
-
-RUN php composer.phar require phpmv/ubiquity-devtools:dev-master phpmv/ubiquity-swoole:dev-master --quiet
-
-RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
-
-RUN chmod 777 -R /ubiquity/.ubiquity/*
-
-#RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /usr/local/etc/php/php.ini
-
-USER www-data
-
-COPY deploy/swoole/swooleMysqlAsyncServices.php app/config/swooleServices.php
-
-CMD /ubiquity/vendor/bin/Ubiquity serve -t=swoole -p=8080 -h=0.0.0.0

+ 1 - 1
frameworks/PHP/ubiquity/ubiquity-swoole-mysql.dockerfile

@@ -32,6 +32,6 @@ RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /usr/loc
 
 USER www-data
 
-COPY deploy/swoole/swooleMysqlServices.php app/config/swooleServices.php
+COPY deploy/conf/swoole/mysql/swooleServices.php app/config/swooleServices.php
 
 CMD /ubiquity/vendor/bin/Ubiquity serve -t=swoole -p=8080 -h=0.0.0.0

+ 1 - 1
frameworks/PHP/ubiquity/ubiquity-swoole.dockerfile

@@ -34,6 +34,6 @@ RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /usr/loc
 
 USER www-data
 
-COPY deploy/swoole/swoolePgsqlServices.php app/config/swooleServices.php
+COPY deploy/conf/swoole/pgsql/swooleServices.php app/config/swooleServices.php
 
 CMD /ubiquity/vendor/bin/Ubiquity serve -t=swoole -p=8080 -h=0.0.0.0

+ 40 - 0
frameworks/PHP/ubiquity/ubiquity-workerman-mysql.dockerfile

@@ -0,0 +1,40 @@
+  
+FROM ubuntu:20.04
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
+RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
+RUN apt-get update -yqq > /dev/null && \
+    apt-get install -yqq php7.4 php7.4-common php7.4-cli php7.4-mysql > /dev/null
+
+RUN apt-get install -yqq composer > /dev/null
+
+RUN apt-get install -y php-pear php-dev libevent-dev > /dev/null
+RUN printf "\n\n /usr/lib/x86_64-linux-gnu/\n\n\nno\n\n\n" | pecl install event > /dev/null && echo "extension=event.so" > /etc/php/7.4/cli/conf.d/event.ini
+
+COPY deploy/conf/php-async.ini /etc/php/7.4/cli/php.ini
+
+ADD ./ /ubiquity
+WORKDIR /ubiquity
+
+RUN chmod -R 777 /ubiquity
+
+RUN ["chmod", "+x", "deploy/run/install-composer.sh"]
+
+RUN deploy/run/install-composer.sh
+
+RUN apt-get update -yqq > /dev/null && \
+    apt-get install -yqq git unzip > /dev/null
+
+RUN php composer.phar require phpmv/ubiquity-devtools:dev-master phpmv/ubiquity-workerman:dev-master --quiet
+
+RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
+
+RUN chmod 777 -R /ubiquity/.ubiquity/*
+
+COPY deploy/conf/workerman/mysql/workerServices.php app/config/workerServices.php
+
+RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/cli/php.ini
+
+CMD /ubiquity/vendor/bin/Ubiquity serve -t=workerman -p=8080 -h=0.0.0.0

+ 2 - 0
frameworks/PHP/ubiquity/ubiquity-workerman.dockerfile

@@ -33,6 +33,8 @@ RUN php composer.phar install --optimize-autoloader --classmap-authoritative --n
 
 RUN chmod 777 -R /ubiquity/.ubiquity/*
 
+COPY deploy/conf/workerman/pgsql/workerServices.php app/config/workerServices.php
+
 RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/cli/php.ini
 
 CMD /ubiquity/vendor/bin/Ubiquity serve -t=workerman -p=8080 -h=0.0.0.0

+ 3 - 1
frameworks/PHP/ubiquity/ubiquity.dockerfile

@@ -20,7 +20,9 @@ RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --q
 
 RUN chmod 777 -R /ubiquity/app/cache/*
 
+COPY deploy/conf/ubiquity-config.php app/config/config.php
+
 RUN echo "opcache.preload=/ubiquity/app/config/preloader.script.php" >> /etc/php/7.4/fpm/php.ini
 
 CMD service php7.4-fpm start && \
-    nginx -c /ubiquity/deploy/nginx.conf -g "daemon off;"
+    nginx -c /ubiquity/deploy/nginx.conf -g "daemon off;"