Skip to content

Commit

Permalink
created benchmark_config and setup.py files for dancer
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalls-techempower committed Apr 22, 2013
1 parent 9bdd43e commit d44a6a8
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 5 deletions.
Empty file added dancer/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions dancer/app.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set serializer => 'JSON';

#my $dbh = database({ driver => 'mysql', database => 'test' });
my $dbh = database({ driver => 'mysql', host => 'ip-10-34-150-134.eu-west-1.compute.internal', database => 'test', username => 'root' });
my $dbh = database({ driver => 'mysql', host => 'localhost', database => 'hello_world', username => 'benchmarkdbuser', password => 'benchmarkdbpass' });

get '/json' => sub {
{ message => 'Hello, World!' }
Expand All @@ -19,7 +19,7 @@
for( 1 .. $queries ) {
my $id = int rand 10000 + 1;
if ( my $row = $dbh->quick_select( 'world', { id => $id } ) ) {
push @response, { id => $id, randomNumber => $row->{randomnumber} };
push @response, { id => $id, randomNumber => $row->{randomNumber} };
}
}
{ \@response }
Expand Down
19 changes: 19 additions & 0 deletions dancer/benchmark_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"framework": "dancer",
"tests": [{
"default": {
"setup_file": "setup",
"json_url": "/json",
"port": 8080,
"sort": 76
},
"raw": {
"setup_file": "setup",
"db_url": "/db",
"query_url": "/db?queries=",
"port": 8080,
"sort": 77
}
}]
}

6 changes: 3 additions & 3 deletions dancer/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
user www;
user USR;

worker_processes 2;

Expand All @@ -16,11 +16,11 @@ http {
tcp_nodelay on;

upstream backendurl {
server unix:/tmp/frameworks-benchmark.sock;
server unix:/home/pfalls/FrameworkBenchmarks/dancer/frameworks-benchmark.sock;
}

server {
listen 8888;
listen 8080;
server_name localhost;

location / {
Expand Down
31 changes: 31 additions & 0 deletions dancer/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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("dancer/app.pl", "localhost", ""+ args.database_host +"")
setup_util.replace_text("dancer/nginx.conf", "USR", getpass.getuser())

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.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/dancer/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
10 changes: 10 additions & 0 deletions installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def __install_server_software(self):
self.__run_command("sudo ringo-admin install oberhamsi/reinhardt")
self.__run_command("sudo ringo-admin install grob/ringo-sqlstore")

#
# Perl
#
self.__run_command("sudo cpan install Plack", send_yes=True)
self.__run_command("sudo cpan install Starman")
self.__run_command("sudo cpan install DBD::mysql")
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)

#######################################
# Webservers
#######################################
Expand Down

0 comments on commit d44a6a8

Please sign in to comment.