12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- pid /tmp/nginx.pid;
- error_log stderr error;
- worker_processes auto;
- events {
- worker_connections 16384;
- multi_accept on;
- }
- http {
- resolver 127.0.0.1;
- 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 8080;
- server_name localhost;
- location / {
- root html;
- index index.html index.htm;
- }
- location /plaintext {
- default_type "text/plain";
- 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!")';
- }
- location ~ /db {
- default_type "application/json";
- #note: next line has cwd
- mruby_content_handler 'CWD/db.rb' cache;
- }
- location ~ /queries {
- default_type "application/json";
- #note: next line has cwd
- mruby_content_handler 'CWD/queries.rb' cache;
- }
- # location ~ /fortunes {
- # default_type "application/html";
- # #note: next line has cwd
- # mruby_content_handler 'CWD/fortunes.rb' cache;
- # }
- }
- }
|