Browse Source

Added Nimrod jester framework.

Dominik Picheta 12 years ago
parent
commit
0381879dd7
9 changed files with 153 additions and 0 deletions
  1. 16 0
      installer.py
  2. 2 0
      jester/.gitignore
  3. 20 0
      jester/README.md
  4. 0 0
      jester/__init__.py
  5. 11 0
      jester/benchmark_config
  6. 66 0
      jester/config/nginx.conf
  7. 9 0
      jester/hello.nim
  8. 0 0
      jester/public/.gitkeep
  9. 29 0
      jester/setup.py

+ 16 - 0
installer.py

@@ -175,6 +175,17 @@ class Installer:
     self.__run_command("./autogen.sh --prefix=/usr/local", cwd="xsp")
     self.__run_command("./autogen.sh --prefix=/usr/local", cwd="xsp")
     self.__run_command("make", cwd="xsp")
     self.__run_command("make", cwd="xsp")
     self.__run_command("sudo make install", cwd="xsp")
     self.__run_command("sudo make install", cwd="xsp")
+    
+    # 
+    # Nimrod
+    # 
+    self.__run_command("wget http://www.nimrod-code.org/download/nimrod_0.9.2.zip")
+    self.__run_command("unzip nimrod_0.9.2.zip")
+    self.__run_command("chmod +x build.sh", cwd="nimrod")
+    self.__run_command("./build.sh", cwd="nimrod")
+    self.__run_command("chmod +x install.sh", cwd="nimrod")
+    self.__run_command("sudo ./install.sh /usr/bin", cwd="nimrod")
+    
     #######################################
     #######################################
     # Webservers
     # Webservers
     #######################################
     #######################################
@@ -286,6 +297,11 @@ class Installer:
     self.__run_command("cabal update")
     self.__run_command("cabal update")
     self.__run_command("cabal install yesod persistent-mysql")
     self.__run_command("cabal install yesod persistent-mysql")
 
 
+    ##############################
+    # Jester
+    ##############################
+    self.__run_command("git clone git://github.com/dom96/jester.git jester/jester")
+
     ##############################################################
     ##############################################################
     #
     #
     # System Tools
     # System Tools

+ 2 - 0
jester/.gitignore

@@ -0,0 +1,2 @@
+nimcache
+hello

+ 20 - 0
jester/README.md

@@ -0,0 +1,20 @@
+# Nimrod Jester Benchmarking Test
+
+This is the Nimrod jester portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### JSON Encoding Test
+* [JSON test source](hello.nim)
+
+
+## Infrastructure Software Versions
+The tests were run with:
+* [Nimrod 0.9.2](http://www.nimrod-code.org/)
+* [Jester a7914d5](https://github.com/dom96/jester/commit/a7914d5ab918debec24343286b3939ccd3c4619d)
+* Nginx 1.4.1
+
+## Test URLs
+
+### JSON Encoding Test
+
+Nimrod:
+localhost:8080/json

+ 0 - 0
jester/__init__.py


+ 11 - 0
jester/benchmark_config

@@ -0,0 +1,11 @@
+{
+  "framework": "jester",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "port": 8080,
+      "sort": 129
+    }
+  }]
+}

+ 66 - 0
jester/config/nginx.conf

@@ -0,0 +1,66 @@
+# Config file based on sinatra's.
+
+# you generally only need one nginx worker unless you're serving
+# large amounts of static files which require blocking disk reads
+worker_processes 8;
+
+# # drop privileges, root is needed on most systems for binding to port 80
+# # (or anything < 1024).  Capability-based security may be available for
+# # your system and worth checking out so you won't need to be root to
+# # start nginx to bind on 80
+# user nobody nogroup; # for systems with a "nogroup"
+#user nobody nobody; # for systems with "nobody" as a group instead
+
+# Feel free to change all paths to suite your needs here, of course
+# pid /tmp/nginx.pid;
+error_log /tmp/nginx.error.log;
+
+events {
+  worker_connections 4096; # increase if you have lots of clients
+  accept_mutex off; # "on" if nginx worker_processes > 1
+  use epoll; # enable for Linux 2.6+
+  # use kqueue; # enable for FreeBSD, OSX
+}
+
+http {
+  # nginx will find this file in the config directory set at nginx build time
+  #include /usr/local/nginx/conf/mime.types;
+
+  # fallback in case we can't determine a type
+  default_type application/octet-stream;
+
+  # click tracking!
+  access_log /tmp/nginx.access.log combined;
+
+  server {
+    # enable one of the following if you're on Linux or FreeBSD
+    listen 8080 default deferred; # for Linux
+    # listen 80 default accept_filter=httpready; # for FreeBSD
+
+    client_max_body_size 4G;
+    server_name _;
+
+    # ~2 seconds is often enough for most folks to parse HTML/CSS and
+    # retrieve needed images/icons/frames, connections are cheap in
+    # nginx so increasing this is generally safe...
+    keepalive_timeout 10;
+
+    # path for static files
+    root /path/to/app/current/public;
+
+    # Prefer to serve static files directly from nginx to avoid unnecessary
+    # data copies from the application server.
+    #
+    # try_files directive appeared in in nginx 0.7.27 and has stabilized
+    # over time.  Older versions of nginx (e.g. 0.6.x) requires
+    # "if (!-f $request_filename)" which was less efficient:
+    # http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127
+    #try_files $uri/index.html $uri.html $uri @app;
+
+    location / {
+      include /usr/local/nginx/conf/scgi_params;
+      scgi_pass localhost:9000;
+    }
+
+  }
+}

+ 9 - 0
jester/hello.nim

@@ -0,0 +1,9 @@
+import jester, strtabs, json, asyncio, sockets
+
+get "/json":
+  var obj = %{"message": %"Hello, World!"}
+  resp($obj)
+
+var disp = newDispatcher()
+disp.register(port = TPort(9000), http=false)
+while disp.poll(): nil

+ 0 - 0
jester/public/.gitkeep


+ 29 - 0
jester/setup.py

@@ -0,0 +1,29 @@
+import subprocess
+import sys
+import setup_util
+import os
+from os.path import expanduser
+
+home = expanduser("~")
+
+def start(args):
+  subprocess.check_call("nimrod c -d:release --path:jester hello.nim", shell=True, cwd="jester")
+  subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/jester/config/nginx.conf", shell=True)
+  
+  subprocess.Popen("./hello > /dev/null", shell=True, cwd="jester")
+  return 0
+
+def stop():
+  subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
+
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'hello' in line:
+      try:
+        pid = int(line.split(None, 2)[1])
+        os.kill(pid, 9)
+      except OSError:
+        pass
+
+  return 0