Browse Source

Add ubiquity-workerman-pgsql (#5119)

* Add workerman-pgsql

* add persistent connection
jcheron 5 years ago
parent
commit
ed14401630

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

@@ -35,6 +35,19 @@ return array(
 			"password" => "benchmarkdbpass", // benchmarkdbpass
 			"options" => [],
 			"cache" => false
+		],
+		'pgsql'=>[
+			"wrapper"=>"\\Ubiquity\\db\\providers\\pdo\\PDOWrapper",
+			"type" => "pgsql",
+			"dbName" => "hello_world",
+			"serverName" => "tfb-database", // tfb-database
+			"port" => 5432,
+			"user" => "benchmarkdbuser", // benchmarkdbuser
+			"password" => "benchmarkdbpass", // benchmarkdbpass
+			"options" => [
+				\PDO::ATTR_PERSISTENT => true
+			],
+			"cache"=>false
 		]
 	],
 	"test" => false,

+ 4 - 0
frameworks/PHP/ubiquity/app/controllers/WorkerFortunes.php

@@ -6,6 +6,10 @@ use Ubiquity\orm\DAO;
 
 class WorkerFortunes extends \Ubiquity\controllers\Controller {
 
+	public function initialize() {
+		\Ubiquity\utils\http\UResponse::setContentType('text/html','utf-8');
+	}
+	
 	public function index() {
 		$fortunes = DAO::getAll(Fortune::class, '', false);
 		$fortunes[] = (new Fortune())->setId(0)->setMessage('Additional fortune added at request time.');

+ 21 - 0
frameworks/PHP/ubiquity/benchmark_config.json

@@ -48,6 +48,27 @@
         "notes": "",
         "versus": "workerman"
       },
+      "workerman-pgsql": {
+        "db_url": "/WorkerDb",
+        "query_url": "/WorkerDb/query/",
+        "fortune_url": "/WorkerFortunes",
+        "update_url": "/WorkerDb/update/",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Fullstack",
+        "database": "Postgres",
+        "framework": "Ubiquity",
+        "language": "PHP",
+        "flavor": "PHP7",
+        "orm": "Full",
+        "platform": "workerman",
+        "webserver": "none",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "ubiquity-workerman-pgsql",
+        "notes": "",
+        "versus": "workerman"
+      },
       "swoole": {
         "json_url": "/Json",
         "plaintext_url": "/Plaintext",

+ 38 - 0
frameworks/PHP/ubiquity/ubiquity-workerman-pgsql.dockerfile

@@ -0,0 +1,38 @@
+  
+FROM ubuntu:19.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.3 php7.3-common php7.3-cli php7.3-pgsql > /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.3/cli/conf.d/event.ini
+
+COPY deploy/conf/php-async.ini /etc/php/7.3/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-techempower-benchmarks phpmv/ubiquity-workerman:dev-techempower-benchmarks phpmv/ubiquity-mysqli:dev-techempower-benchmarks --quiet
+
+RUN php composer.phar install --optimize-autoloader --classmap-authoritative --no-dev --quiet
+
+RUN chmod 777 -R /ubiquity/.ubiquity/*
+
+RUN sed -i "s|worker|pgsql|g" /ubiquity/app/config/workerServices.php
+
+CMD /ubiquity/vendor/bin/Ubiquity serve -t=workerman -p=8080 -h=0.0.0.0