Browse Source

Add an implementation using H2O and mruby (#2799)

Only the JSON serialization and plaintext test types have been
implemented.
Anton Kirilov 8 years ago
parent
commit
71750106fd

+ 1 - 0
.travis.yml

@@ -169,6 +169,7 @@ env:
     - "TESTDIR=Python/wheezyweb"
     - "TESTDIR=Python/wsgi"
     - "TESTDIR=Ruby/grape"
+    - "TESTDIR=Ruby/h2o_mruby"
     - "TESTDIR=Ruby/hanami"
     - "TESTDIR=Ruby/ngx_mruby"
     - "TESTDIR=Ruby/padrino"

+ 9 - 0
frameworks/Ruby/h2o_mruby/README.md

@@ -0,0 +1,9 @@
+# h2o_mruby
+
+This is a framework implementation using the [H2O](https://h2o.examp1e.net/) HTTP server
+and the [mruby](https://mruby.org/) implementation of the [Ruby](https://www.ruby-lang.org/)
+language.
+
+## Requirements
+
+H2O

+ 23 - 0
frameworks/Ruby/h2o_mruby/benchmark_config.json

@@ -0,0 +1,23 @@
+{
+  "framework": "h2o_mruby",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "None",
+      "framework": "None",
+      "language": "Ruby",
+      "orm": "Raw",
+      "platform": "None",
+      "webserver": "H2O",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "h2o_mruby",
+      "notes": ""
+    }
+  }]
+}

+ 16 - 0
frameworks/Ruby/h2o_mruby/h2o.conf

@@ -0,0 +1,16 @@
+listen: 8080
+max-connections: 32768
+error-log: /proc/self/fd/2
+hosts:
+  "0.0.0.0":
+    paths:
+      "/json":
+        mruby.handler: |
+          Proc.new do |env|
+            [200, {'content-type' => 'application/json'}, [{:message => "Hello, World!"}.to_json]]
+          end
+      "/plaintext":
+        mruby.handler: |
+          Proc.new do |env|
+            [200, {'content-type' => 'text/plain'}, ["Hello, World!"]]
+          end

+ 5 - 0
frameworks/Ruby/h2o_mruby/setup.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+fw_depends h2o
+
+"${H2O_HOME}/bin/h2o" -c "$TROOT/h2o.conf" -m daemon

+ 3 - 1
toolset/setup/linux/webservers/h2o.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+fw_depends ruby-2.4
+
 fw_installed h2o && return 0
 
 H2O_HOME="${IROOT}/h2o"
@@ -12,7 +14,7 @@ fw_get -O "https://github.com/h2o/h2o/archive/$ARCHIVE"
 fw_untar "$ARCHIVE"
 pushd "$BUILD_DIR"
 cmake -DCMAKE_INSTALL_PREFIX="$H2O_HOME" -DCMAKE_C_FLAGS="-flto -march=native" \
-	-DCMAKE_AR=/usr/bin/gcc-ar -DCMAKE_RANLIB=/usr/bin/gcc-ranlib
+      -DCMAKE_AR=/usr/bin/gcc-ar -DCMAKE_RANLIB=/usr/bin/gcc-ranlib -DWITH_MRUBY=on
 make -j "$(nproc)" install
 popd
 rm -rf "$BUILD_DIR"