Browse Source

Add workerman with postgres (#5076)

Joan Miquel 5 years ago
parent
commit
63a937ea42

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

@@ -23,6 +23,27 @@
       "display_name": "workerman",
       "notes": "",
       "versus": "php"
+    },
+    "pgsql": {
+      "db_url": "/db",
+      "query_url": "/db?queries=",
+      "update_url": "/update?queries=",
+      "fortune_url": "/fortune",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "Postgres",
+      "framework": "None",
+      "language": "PHP",
+      "flavor": "PHP7",
+      "orm": "Raw",
+      "platform": "workerman",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "workerman postgres",
+      "notes": "",
+      "versus": "php"
     }
   }]
 }

+ 1 - 1
frameworks/PHP/workerman/server.php

@@ -10,7 +10,7 @@ $http_worker                = new Worker('http://0.0.0.0:8080');
 $http_worker->count         = (int) shell_exec('nproc') ?? 64;
 $http_worker->onWorkerStart = function () {
     global $pdo;
-    $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world;charset=utf8',
+    $pdo = new PDO('mysql:host=tfb-database;dbname=hello_world',
         'benchmarkdbuser', 'benchmarkdbpass');
 };
 $http_worker->onMessage = static function ($connection) {

+ 24 - 0
frameworks/PHP/workerman/workerman-pgsql.dockerfile

@@ -0,0 +1,24 @@
+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 php.ini /etc/php/7.3/cli/php.ini
+
+ADD ./ /workerman
+WORKDIR /workerman
+
+RUN sed -i "s|PDO('mysql:|PDO('pgsql:|g" server.php
+
+RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
+
+CMD php /workerman/server.php start