Sfoglia il codice sorgente

Update ubiquity react (128 workers) (#4922)

* Update workers to 512

+small updates

* Update Db.php

* remove emulate_prepares

* pm workers=128

* Update index.php

* Update composer.json
jcheron 6 anni fa
parent
commit
965d23884b

+ 23 - 13
frameworks/PHP/ubiquity/app/config/config.php

@@ -1,17 +1,27 @@
 <?php
 return array(
-		"database"=>[
-				"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
+	"database" => [
+		"type" => "mysql",
+		"dbName" => "hello_world",
+		"serverName" => "tfb-database", // tfb-database
+		"port" => "3306",
+		"user" => "benchmarkdbuser", // benchmarkdbuser
+		"password" => "benchmarkdbpass", // benchmarkdbpass
+		"options" => [
+			\PDO::ATTR_PERSISTENT => true
 		],
-		"test"=>false,
-		"debug"=>false,
-		"cache"=>["directory"=>"cache/","system"=>"Ubiquity\\cache\\system\\ArrayCache","params"=>[]],
-		"mvcNS"=>["models"=>"models","controllers"=>"controllers","rest"=>""]
+		"cache" => false
+	],
+	"test" => false,
+	"debug" => false,
+	"cache" => [
+		"directory" => "cache/",
+		"system" => "Ubiquity\\cache\\system\\ArrayCache",
+		"params" => []
+	],
+	"mvcNS" => [
+		"models" => "models",
+		"controllers" => "controllers",
+		"rest" => ""
+	]
 );

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

@@ -14,20 +14,19 @@ class Db extends Controller {
 
 	public function initialize() {
 		UResponse::setContentType('application/json');
-		$config = Startup::getConfig();
-		DAO::startDatabase($config);
+		DAO::startDatabase(Startup::$config);
 	}
 
 	public function index() {
-		$world = DAO::getById(World::class, mt_rand(1, 10000), false);
+		$world = DAO::getById(World::class, \mt_rand(1, 10000), false);
 		echo \json_encode($world->_rest);
 	}
 
 	public function query($queries = 1) {
 		$worlds = [];
-		$queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
+		$queries = \min(\max($queries, 1), 500);
 		for ($i = 0; $i < $queries; ++ $i) {
-			$world = DAO::getById(World::class, mt_rand(1, 10000), false);
+			$world = DAO::getById(World::class, \mt_rand(1, 10000), false);
 			$worlds[] = $world->_rest;
 		}
 		echo \json_encode($worlds);
@@ -35,10 +34,10 @@ class Db extends Controller {
 
 	public function update($queries = 1) {
 		$worlds = [];
-		$queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
+		$queries = \min(\max($queries, 1), 500);
 		for ($i = 0; $i < $queries; ++ $i) {
-			$world = DAO::getById(World::class, mt_rand(1, 10000), false);
-			$world->setRandomNumber(mt_rand(1, 10000));
+			$world = DAO::getById(World::class, \mt_rand(1, 10000), false);
+			$world->randomNumber = \mt_rand(1, 10000);
 			DAO::update($world);
 			$worlds[] = $world->_rest;
 		}

+ 1 - 2
frameworks/PHP/ubiquity/app/controllers/Fortunes.php

@@ -11,8 +11,7 @@ class Fortunes extends Controller {
 
 	public function initialize() {
 		Startup::$templateEngine = new MicroTemplateEngine();
-		$config = Startup::getConfig();
-		DAO::startDatabase($config);
+		DAO::startDatabase(Startup::$config);
 	}
 
 	public function index() {

+ 13 - 9
frameworks/PHP/ubiquity/app/models/World.php

@@ -1,21 +1,23 @@
 <?php
-
 namespace models;
 
 class World {
-	
+
 	/**
+	 *
 	 * @id
 	 * @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)")
-	 **/
-	private $id;
-	
+	 */
+	public $id;
+
 	/**
+	 *
 	 * @column("name"=>"randomNumber","nullable"=>false,"dbType"=>"int(11)")
-	 **/
-	private $randomNumber;
-	
+	 */
+	public $randomNumber;
+
 	/**
+	 *
 	 * @return mixed
 	 */
 	public function getId() {
@@ -23,6 +25,7 @@ class World {
 	}
 
 	/**
+	 *
 	 * @return mixed
 	 */
 	public function getRandomNumber() {
@@ -30,6 +33,7 @@ class World {
 	}
 
 	/**
+	 *
 	 * @param mixed $id
 	 */
 	public function setId($id) {
@@ -37,11 +41,11 @@ class World {
 	}
 
 	/**
+	 *
 	 * @param mixed $randomNumber
 	 */
 	public function setRandomNumber($randomNumber) {
 		$this->randomNumber = $randomNumber;
 	}
-
 }
 

+ 1 - 1
frameworks/PHP/ubiquity/app/views/Fortunes/index.php

@@ -1,4 +1,4 @@
 <!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>
 <?php foreach ($fortunes as $item) : ?>
-<tr><td><?= $item->id ?></td><td><?= htmlentities($item->message) ?></td></tr>
+<tr><td><?= $item->id ?></td><td><?= \htmlentities($item->message) ?></td></tr>
 <?php endforeach ?></table></body></html>

+ 1 - 1
frameworks/PHP/ubiquity/composer.json

@@ -1,7 +1,7 @@
 {
 	"require" : {
 		"php" : "^7.1",
-		"phpmv/ubiquity" : "dev-master"
+		"phpmv/ubiquity" : "2.3.x-dev"
 	},
 	"require-dev" : {
 		"monolog/monolog" : "^1.24",

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

@@ -26,4 +26,4 @@ RUN chmod 777 -R /ubiquity/.ubiquity/*
 
 RUN chmod 777 /ubiquity/vendor/bin/ppm
 
-CMD /ubiquity/vendor/bin/ppm --bridge='\PHPPM\Ubiquity' --bootstrap='\PHPPM\Ubiquity' start --debug 0 --logging 0 --workers 64 --max-requests 1024 --host=0.0.0.0 --port=8080
+CMD /ubiquity/vendor/bin/ppm --bridge='\PHPPM\Ubiquity' --bootstrap='\PHPPM\Ubiquity' start --debug 0 --logging 0 --workers 128 --max-requests 1024 --host=0.0.0.0 --port=8080