Browse Source

added setup and benchmark_config files for kelp

Patrick Falls 12 years ago
parent
commit
066d9a174f
8 changed files with 61 additions and 8 deletions
  1. 1 1
      dancer/nginx.conf
  2. 2 1
      dancer/setup.py
  3. 1 0
      installer.py
  4. 0 0
      kelp/__init__.py
  5. 3 3
      kelp/app.pl
  6. 19 0
      kelp/benchmark_config
  7. 3 3
      kelp/nginx.conf
  8. 32 0
      kelp/setup.py

+ 1 - 1
dancer/nginx.conf

@@ -1,4 +1,4 @@
-user USR;
+user pfalls;
 
 worker_processes 2;
 

+ 2 - 1
dancer/setup.py

@@ -10,9 +10,10 @@ home = expanduser("~")
 def start(args):
   setup_util.replace_text("dancer/app.pl", "localhost", ""+ args.database_host +"")
   setup_util.replace_text("dancer/nginx.conf", "USR", getpass.getuser())
+  setup_util.replace_text("dancer/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + home + "/FrameworkBenchmarks")
 
   try:
-    subprocess.Popen("plackup -E production -s Starman --workers=2 -l " + home + "/FrameworkBenchmarks/dancer/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="dancer")
+    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l " + home + "/FrameworkBenchmarks/dancer/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="dancer")
     subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/dancer/nginx.conf", shell=True)
     return 0
   except subprocess.CalledProcessError:

+ 1 - 0
installer.py

@@ -137,6 +137,7 @@ class Installer:
     self.__run_command("sudo cpan install Dancer")
     self.__run_command("sudo cpan install Dancer::Plugin::Database")
     self.__run_command("sudo cpan install JSON", send_yes=True)
+    self.__run_command("sudo cpan install Kelp", send_yes=True)
 
     #######################################
     # Webservers

+ 0 - 0
kelp/__init__.py


+ 3 - 3
kelp/app.pl

@@ -3,10 +3,10 @@ use Kelp::Less;
 use DBI;
 
 attr dbh => sub {
-    my $database = 'test';
-    my $host     = 'ip-10-34-150-134.eu-west-1.compute.internal';
+    my $database = 'hello_world';
+    my $host     = 'localhost';
     my $dsn      = 'dbi:mysql:database=$database;host=$host;port=3306';
-    DBI->connect( $dsn, 'root', '', {} );
+    DBI->connect( $dsn, 'benchmarkdbuser', 'benchmarkdbpass', {} );
 };
 
 get '/json' => sub {

+ 19 - 0
kelp/benchmark_config

@@ -0,0 +1,19 @@
+{
+  "framework": "kelp",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "port": 8080,
+      "sort": 78
+    },
+    "raw": {
+      "setup_file": "setup",
+      "db_url": "/db",
+      "query_url": "/db?queries=",
+      "port": 8080,
+      "sort": 79
+    }
+  }]
+}
+

+ 3 - 3
kelp/nginx.conf

@@ -1,4 +1,4 @@
-user www;
+user USR;
 
 worker_processes 2;
 
@@ -16,11 +16,11 @@ http {
   tcp_nodelay      on;
 
   upstream backendurl {
-    server unix:/tmp/frameworks-benchmark.sock;
+    server unix:/home/ubuntu/FrameworkBenchmarks/kelp/frameworks-benchmark.sock;
   }
 
   server {
-    listen 8888;
+    listen 8080;
     server_name localhost;
 
     location / {

+ 32 - 0
kelp/setup.py

@@ -0,0 +1,32 @@
+import subprocess
+import sys
+import setup_util
+from os.path import expanduser
+import os
+import getpass
+
+home = expanduser("~")
+
+def start(args):
+  setup_util.replace_text("kelp/app.pl", "localhost", ""+ args.database_host +"")
+  setup_util.replace_text("kelp/nginx.conf", "USR", getpass.getuser())
+  setup_util.replace_text("kelp/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + home + "/FrameworkBenchmarks")
+
+  try:
+    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l " + home + "/FrameworkBenchmarks/kelp/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="kelp")
+    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/kelp/nginx.conf", shell=True)
+    return 0
+  except subprocess.CalledProcessError:
+    return 1
+def stop():
+  try:
+    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 'plackup' in line:
+        pid = int(line.split(None, 2)[1])
+        os.kill(pid, 9)
+    return 0
+  except subprocess.CalledProcessError:
+    return 1