Browse Source

Removed the 'xsbt-web-plugin' from the tests and integrated SBT assembly to package the benchmark runner into a standalone JAR. Updated setup.py too.

Mark Kolich 11 years ago
parent
commit
609ede5ed5

+ 1 - 0
curacao/.gitignore

@@ -4,3 +4,4 @@
 /.project
 /.project
 /.classpath
 /.classpath
 /.cache
 /.cache
+/dist

+ 1 - 1
curacao/benchmark_config

@@ -16,7 +16,7 @@
       "webserver": "None",
       "webserver": "None",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
-      "display_name": "curacao",
+      "display_name": "Curacao",
       "notes": "",
       "notes": "",
       "versus": ""
       "versus": ""
     }
     }

+ 12 - 5
curacao/build.sbt

@@ -1,3 +1,5 @@
+import AssemblyKeys._
+
 name := "curacao-benchmark"
 name := "curacao-benchmark"
 
 
 organization := "com.kolich"
 organization := "com.kolich"
@@ -11,10 +13,9 @@ resolvers ++= Seq(
 )
 )
 
 
 libraryDependencies ++= Seq(
 libraryDependencies ++= Seq(
-  "com.kolich.curacao" % "curacao" % "2.0-M10",
-  "com.kolich.curacao" % "curacao-gson" % "2.0-M10",
-  "org.eclipse.jetty" % "jetty-webapp" % "9.1.1.v20140108" % "container",
-  "org.eclipse.jetty" % "jetty-plus" % "9.1.1.v20140108" % "container",
+  "com.kolich.curacao" % "curacao" % "2.0-M10" % "compile",
+  "com.kolich.curacao" % "curacao-gson" % "2.0-M10" % "compile",
+  "org.eclipse.jetty" % "jetty-webapp" % "9.1.1.v20140108" % "compile",
   "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
   "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
   "org.slf4j" % "slf4j-api" % "1.7.2" % "compile",
   "org.slf4j" % "slf4j-api" % "1.7.2" % "compile",
   "ch.qos.logback" % "logback-core" % "1.0.7" % "compile",
   "ch.qos.logback" % "logback-core" % "1.0.7" % "compile",
@@ -23,4 +24,10 @@ libraryDependencies ++= Seq(
 
 
 classDirectory in Compile <<= baseDirectory(new File(_, "target/classes"))
 classDirectory in Compile <<= baseDirectory(new File(_, "target/classes"))
 
 
-seq(webSettings :_*)
+sbtassembly.Plugin.assemblySettings
+
+mainClass in assembly := Some("benchmark.Bootstrap")
+
+outputPath in assembly := file("dist/curacao-standalone.jar")
+
+assemblyOption in assembly ~= { _.copy(includeScala = false) }

+ 2 - 2
curacao/project/plugins.sbt

@@ -1,3 +1,3 @@
-addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.7.0")
-
 addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
 addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
+
+addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.2")

+ 9 - 6
curacao/setup.py

@@ -1,24 +1,28 @@
 
 
 import subprocess
 import subprocess
 import sys
 import sys
+import time
 import os
 import os
 
 
 def start(args, logfile, errfile):
 def start(args, logfile, errfile):
   if os.name == 'nt':
   if os.name == 'nt':
-    subprocess.check_call('"..\\sbt\\sbt.bat" ";start;shell"', shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
+    subprocess.check_call('"..\\sbt\\sbt.bat" assembly', shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
   else:
   else:
-    subprocess.check_call('../sbt/sbt ";start;shell"', shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
-    
+    subprocess.check_call("../sbt/sbt assembly", shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
+
+  subprocess.Popen("java -jar dist/curacao-standalone.jar", shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
+   
+  time.sleep(5)
   return 0
   return 0
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):
   if os.name == 'nt':
   if os.name == 'nt':
-    subprocess.check_call("wmic process where \"CommandLine LIKE '%sbt-launch%'\" call terminate", stderr=errfile, stdout=logfile)
+    subprocess.check_call("wmic process where \"CommandLine LIKE '%curacao-standalone%'\" call terminate", stderr=errfile, stdout=logfile)
   else:
   else:
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     out, err = p.communicate()
     out, err = p.communicate()
     for line in out.splitlines():
     for line in out.splitlines():
-      if 'sbt-launch' in line:
+      if 'curacao-standalone' in line:
         try:
         try:
           pid = int(line.split(None, 2)[1])
           pid = int(line.split(None, 2)[1])
           os.kill(pid, 15)
           os.kill(pid, 15)
@@ -29,4 +33,3 @@ def stop(logfile, errfile):
 
 
 ##start([], open('log.out','a'), open('error.out','a'))
 ##start([], open('log.out','a'), open('error.out','a'))
 ##stop(open('log.out','a'), open('error.out','a'))
 ##stop(open('log.out','a'), open('error.out','a'))
-

+ 34 - 0
curacao/src/main/java/benchmark/Bootstrap.java

@@ -0,0 +1,34 @@
+package benchmark;
+
+import com.kolich.curacao.CuracaoDispatcherServlet;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+public final class Bootstrap {
+
+    public static void main(final String[] args) throws Exception {
+
+        final Server server = new Server(8080);
+
+        final ServletHandler handler = new ServletHandler();
+        handler.setServer(server);
+
+        final ServletHolder holder = handler.addServletWithMapping(CuracaoDispatcherServlet.class, "/");
+        holder.setAsyncSupported(true); // Async supported = true
+        holder.setInitOrder(1); // Load on startup = true
+
+        final WebAppContext context = new WebAppContext();
+        context.setContextPath("/");
+        context.setResourceBase("src/main/webapp");
+        context.addServlet(holder, "/");
+
+        server.setHandler(context);
+
+        server.start();
+        server.join();
+
+    }
+
+}

+ 2 - 2
curacao/src/main/resources/application.conf

@@ -2,10 +2,10 @@ curacao {
 
 
   boot-package = "benchmark"
   boot-package = "benchmark"
 
 
-  ## Never timeout
+  ## Never timeout.
   async-context-timeout = 0
   async-context-timeout = 0
 
 
-  ## Both the request and response thread pools are 'unbounded'
+  ## Both the request and response thread pools are "unbounded" intentionally.
   pools.request.size = 0
   pools.request.size = 0
   pools.response.size = 0
   pools.response.size = 0
 
 

+ 0 - 21
curacao/src/main/webapp/WEB-INF/web.xml

@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
-         version="3.0">
-
-    <display-name>curacao-benchmark</display-name>
-    <description>Curacao benchmark for TechEmpower Framework Benchmarks.</description>
-
-    <servlet>
-        <servlet-name>CuracaoDispatcherServlet</servlet-name>
-        <servlet-class>com.kolich.curacao.CuracaoDispatcherServlet</servlet-class>
-        <load-on-startup>1</load-on-startup>
-        <async-supported>true</async-supported>
-    </servlet>
-    <servlet-mapping>
-        <servlet-name>CuracaoDispatcherServlet</servlet-name>
-        <url-pattern>/*</url-pattern>
-    </servlet-mapping>
-
-</web-app>