|
@@ -1,7 +1,5 @@
|
|
|
-#pid /tmp/nginx.pid;
|
|
|
-
|
|
|
-#error_log stderr error;
|
|
|
-
|
|
|
+pid /tmp/nginx.pid;
|
|
|
+error_log stderr error;
|
|
|
|
|
|
events {
|
|
|
worker_connections 16384;
|
|
@@ -9,15 +7,11 @@ events {
|
|
|
|
|
|
http {
|
|
|
resolver 127.0.0.1;
|
|
|
- #access_log off;
|
|
|
-
|
|
|
-# https://github.com/matsumoto-r/ngx_mruby/wiki/Class-and-Method#nginxrequest-class
|
|
|
-
|
|
|
- # db connection pool
|
|
|
- mruby_init_worker_code 'Userdata.new("my_#{Process.pid}").db = MySQL::Database.new("DBHOSTNAME", "root", "", "benchmark")';
|
|
|
+ access_log off;
|
|
|
+ mruby_init_worker_code 'Userdata.new("my_#{Process.pid}").db = MySQL::Database.new("DBHOSTNAME", "benchmarkdbuser", "benchmarkdbpass", "hello_world")';
|
|
|
mruby_exit_worker_code 'db = Userdata.new("my_#{Process.pid}").db ; db.close if db';
|
|
|
server {
|
|
|
- listen 8000;
|
|
|
+ listen 8080;
|
|
|
server_name localhost;
|
|
|
|
|
|
location / {
|
|
@@ -27,30 +21,31 @@ http {
|
|
|
|
|
|
location /plaintext {
|
|
|
default_type "text/plain";
|
|
|
- mruby_content_handler_code 'Nginx.rputs "Hello World!"';
|
|
|
+ mruby_content_handler_code 'Nginx.rputs "Hello, world!"';
|
|
|
}
|
|
|
|
|
|
location /json {
|
|
|
default_type "application/json";
|
|
|
- mruby_content_handler_code 'Nginx.rputs JSON::stringify("message" => "Hello World!")';
|
|
|
+ mruby_content_handler_code 'Nginx.rputs JSON::stringify("message" => "Hello, World!")';
|
|
|
}
|
|
|
|
|
|
location ~ /db {
|
|
|
default_type "application/json";
|
|
|
- mruby_content_handler 'CWD/nginx_mruby/db.rb' cache;
|
|
|
+ #note: next line has cwd
|
|
|
+ mruby_content_handler 'CWD/db.rb' cache;
|
|
|
}
|
|
|
|
|
|
location ~ /queries {
|
|
|
default_type "application/json";
|
|
|
- mruby_content_handler 'CWD/nginx_mruby/queries.rb' cache;
|
|
|
+ #note: next line has cwd
|
|
|
+ mruby_content_handler 'CWD/queries.rb' cache;
|
|
|
}
|
|
|
|
|
|
- location ~ /fotunes {
|
|
|
- default_type "application/html";
|
|
|
- mruby_content_handler 'CWD/nginx_mruby/fotunes.rb' cache;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+# location ~ /fortunes {
|
|
|
+# default_type "application/html";
|
|
|
+# #note: next line has cwd
|
|
|
+# mruby_content_handler 'CWD/fortunes.rb' cache;
|
|
|
+# }
|
|
|
|
|
|
#location ~ \.rb$ {
|
|
|
# default_type "application/json";
|