[tor-commits] [onionoo/master] Switch from Tomcat to embedded Jetty.

karsten at torproject.org karsten at torproject.org
Mon Nov 17 11:15:37 UTC 2014


commit b4d4121bdac56636c3d48669e2e5cec1379f514e
Author: iwakeh <iwakeh at users.ourproject.org>
Date:   Mon Sep 22 19:00:00 2014 +0000

    Switch from Tomcat to embedded Jetty.
    
    Running the servlet inside Tomcat works okay, but it's not really
    convenient for deployment.  Let's switch to running from the command line
    and using our own embedded Jetty server.
    
    Related to this change, switch to running hourly update process from
    previously generated .jar file rather than using Ant.
    
    Implements #13089.
---
 .gitignore                                         |    3 +-
 CONTRIB.md                                         |   25 -----
 INSTALL                                            |  101 ++++++++---------
 bin/update.sh                                      |    3 -
 build.xml                                          |  114 ++++++++++++++++----
 etc/jetty.xml                                      |   45 ++++++++
 etc/logback.xml                                    |   47 ++++++--
 etc/web.xml.template                               |   23 ++++
 logback.xml                                        |   66 ------------
 .../org/torproject/onionoo/server/ServerMain.java  |   31 ++++++
 vagrant/bootstrap.sh                               |    3 -
 11 files changed, 275 insertions(+), 186 deletions(-)

diff --git a/.gitignore b/.gitignore
index f45b088..80c5ae5 100755
--- a/.gitignore
+++ b/.gitignore
@@ -5,8 +5,7 @@ etc/context.xml
 etc/web.xml
 geoip/
 in/
-log
-onionoo.war
+dist/
 out/
 status/
 
diff --git a/CONTRIB.md b/CONTRIB.md
index 3daf91a..d971ec4 100644
--- a/CONTRIB.md
+++ b/CONTRIB.md
@@ -87,31 +87,6 @@ host system, which performs not really well.
 
 Read the INSTALL file and make the appropriate changes to adapt everything
 to your setup, e.g., memory settings.
-Compile Onionoo, run the unit tests and then the cron part of it:
-
-```
-ant compile
-ant test
-ant run
-```
-
-This step may take an hour or more.  Onionoo downloads the last three days
-of Tor descriptors, which is about 2 GiB, and processes them.
-
-Once these steps are done, deploy the servlet to the local Tomcat server:
-
-```
-ant war
-```
-
-Test the Onionoo service using a browser on the host (port 8080 on the
-guest is forwarded to the host).  Sample URL:
-
-http://localhost:8080/onionoo/summary?limit=2
-
-Note that Tomcat's default server.xml needs no changing for running in the
-development environment.
-See the INSTALL file for necessary changes in the production environment.
 
 ## Documentation overview
 
diff --git a/INSTALL b/INSTALL
index ff638d1..89f4db9 100644
--- a/INSTALL
+++ b/INSTALL
@@ -11,8 +11,8 @@ $ git clone https://git.torproject.org/onionoo.git /srv/onionoo/
 $ cd /srv/onionoo
 
 
-Install Java 1.7 or higher, ant 1.8 or higher, and Tomcat 6
------------------------------------------------------------
+Install Java 1.7 or higher and ant 1.8 or higher
+------------------------------------------------
 
 $ javac -version
 javac 1.7.0_65
@@ -67,73 +67,62 @@ Test the hourly data processing process
 ---------------------------------------
 
 Run the data processing process that will afterwards be run once per hour.
-Currently, memory is set to 4G.  If you have more or less RAM to spare,
-change the value for the maxmemory.value property near the top of the
-build.xml file.
+
+Create a .jar file:
+
+$ ant jar
+
 The initial run may take a while:
 
-$ ant run
+$ java -DLOGBASE=/path/to/logfiles -Xmx4g -jar dist/onionoo-<version>.jar
 
 
 Set up an hourly cronjob
 ------------------------
 
-Check the contents of bin/update.sh and whether they match the commands
-that worked for you.  Once they do, add a crontab line similar to this
-one:
-
-15 * * * * cd /srv/onionoo/ && bin/update.sh
-
-
-Configure Tomcat
-----------------
-
-The following file may be a useful Tomcat configuration file.
-Make changes according to your server setup, i.e. replace ${your-host-ip}
-with your ip address and the like (ports, lognames and paths).
-Put it in /etc/tomcat6/server.xml:
-
-<Server port="8005" shutdown="SHUTDOWN">
-  <Service name="Catalina">
-    <Connector port="8080" maxHttpHeaderSize="8192"
-               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
-               enableLookups="false" redirectPort="8443" acceptCount="100"
-               connectionTimeout="20000" disableUploadTimeout="true"
-               compression="on" compressionMinSize="2048"
-               noCompressionUserAgents="gozilla, traviata"
-               compressableMimeType="text/html,application/json" />
-    <Engine name="Catalina" defaultHost="${your-host-ip}">
-      <Host name="${your-host-ip}" appBase="webapps"
-            unpackWARs="true" autoDeploy="true"
-            xmlValidation="false" xmlNamespaceAware="false">
-        <Alias>${your-host-ip}</Alias>
-        <Valve className="org.apache.catalina.valves.AccessLogValve"
-               directory="logs" prefix="onionoo_access_log." suffix=".txt"
-               pattern="%l %u %t %r %s %b" resolveHosts="false"/>
-      </Host>
-    </Engine>
-  </Service>
-</Server>
-
-It may also be necessary to increase Tomcat's maximum heap space.  Do this
-by editing JAVA_OPTS in /etc/default/tomcat6 and change "-Xmx128m" to
-"-Xmx512m".
-
-
-Deploy the Tomcat application
------------------------------
+Add a crontab line similar to the command above:
+
+15 * * * * cd /srv/onionoo/ && java -DLOGBASE=/path/to/logfiles \
+                                    -Xmx4g -jar dist/onionoo-<version>.jar
+
+
+Run the web server
+------------------
 
 Create a .war file:
 
 $ ant war
 
-Create a symbolic link to the .war file, so that non-root users can
-re-deploy the application in the future.  Run the following commands as
-root:
+Start the Onionoo server
 
-# cd /var/lib/tomcat6/webapps/
-# ln -s /srv/onionoo/onionoo.war onionoo.war
+$ java -DLOGBASE=/path/to/logfiles -Xmx4g -jar dist/onionoo-<version>.war
 
 The Onionoo server should now be available at
-http://localhost:8080/onionoo/.
+http://localhost:8080/.
+
+
+Configure Embedded Jetty
+------------------------
+
+Settings for the embedded jetty can be found in etc/jetty.xml
+If you change anything, run
+
+$ ant clean war
+
+again.
+
+
+Configure logging
+-----------------
+
+Logging can be configured inside etc/logback.xml
+If you change anything, run
+
+$ ant clean war jar
+
+again.
+
+The command line option LOGBASE is the path for the log files.
+In case you forget to set it, you'll find the logs in the current
+path in the folder LOGBASE_IS_UNDEFINED/
 
diff --git a/bin/update.sh b/bin/update.sh
deleted file mode 100755
index 9294f41..0000000
--- a/bin/update.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-ant run >> log && cat errors
-
diff --git a/build.xml b/build.xml
index 8f71f4d..0bea931 100644
--- a/build.xml
+++ b/build.xml
@@ -1,8 +1,12 @@
-<project default="run" name="onionoo" basedir=".">
-  <property name="maxmemory.value" value="4g"/>
+<project default="dist" name="onionoo" basedir=".">
+
+  <property name="onionoo.protocol.version" value="2.0"/>
+  <property name="release.version"
+            value="${onionoo.protocol.version}.0"/>
   <property name="javasources" value="src/main/java"/>
   <property name="tests" value="src/test/java"/>
   <property name="classes" value="classes"/>
+  <property name="dist" value="dist"/>
   <property name="config" value="etc"/>
   <property name="webxmlfile" value="${config}/web.xml"/>
   <property name="contextxmltemplate"
@@ -11,8 +15,12 @@
   <property name="webxmltemplate"
             value="${config}/web.xml.template"/>
   <property name="webxml" value="${config}/web.xml"/>
-  <property name="warfile" value="onionoo.war"/>
+  <property name="warfile"
+            value="${dist}/onionoo-${release.version}.war"/>
+  <property name="jarfile"
+            value="${dist}/onionoo-${release.version}.jar"/>
   <property name="source-and-target-java-version" value="1.7" />
+
   <path id="classpath">
     <pathelement path="${classes}"/>
     <fileset dir="/usr/share/java">
@@ -25,12 +33,22 @@
       <include name="logback-classic-1.0.4.jar"/>
       <include name="logback-core-1.0.4.jar"/>
       <include name="slf4j-api-1.6.5.jar"/>
+      <include name="jetty8-server-8.1.3.v20120416.jar"/>
+      <include name="jetty8-servlets-8.1.3.v20120416.jar"/>
+      <include name="jetty8-servlet-8.1.3.v20120416.jar"/>
+      <include name="jetty8-util-8.1.3.v20120416.jar"/>
+      <include name="jetty8-http-8.1.3.v20120416.jar"/>
+      <include name="jetty8-io-8.1.3.v20120416.jar"/>
+      <include name="jetty8-xml-8.1.3.v20120416.jar"/>
+      <include name="jetty8-webapp-8.1.3.v20120416.jar"/>
+      <include name="jetty8-continuation-8.1.3.v20120416.jar"/>
+      <include name="jetty8-security-8.1.3.v20120416.jar"/>
     </fileset>
     <fileset dir="deps/metrics-lib">
       <include name="descriptor.jar"/>
     </fileset>
     <fileset dir="${config}">
-      <include name="logback.xml"/>
+      <include name="logback.xml,jetty.xml"/>
     </fileset>
   </path>
 
@@ -38,13 +56,14 @@
     <copy file="${contextxmltemplate}" tofile="${contextxml}"/>
     <copy file="${webxmltemplate}" tofile="${webxml}"/>
     <mkdir dir="${classes}"/>
+    <mkdir dir="${dist}"/>
   </target>
 
   <target name="clean" >
     <delete includeEmptyDirs="true">
       <fileset dir="${classes}" defaultexcludes="false" includes="**" />
+      <fileset dir="${dist}" defaultexcludes="false" includes="**" />
     </delete>
-    <delete file="${warfile}"/>
   </target>
 
   <target name="metrics-lib">
@@ -87,38 +106,93 @@
       </batchtest>
     </junit>
   </target>
+
   <target name="war"
           depends="compile">
     <war destfile="${warfile}"
          webxml="${webxmlfile}">
       <fileset dir="web"/>
-      <lib dir="deps/metrics-lib">
+      <zipgroupfileset dir="deps/metrics-lib">
         <include name="descriptor.jar"/>
-      </lib>
-      <lib dir="/usr/share/java">
-        <include name="slf4j-api-1.6.5.jar"/>
-        <include name="logback-classic-1.0.4.jar"/>
-        <include name="logback-core-1.0.4.jar"/>
+      </zipgroupfileset>
+      <zipgroupfileset dir="/usr/share/java">
         <include name="commons-codec-1.6.jar"/>
         <include name="commons-compress-1.4.1.jar"/>
         <include name="commons-lang3-3.1.jar"/>
         <include name="gson-2.1.jar"/>
-      </lib>
-      <classes dir="${classes}"/>
+        <include name="servlet-api-3.0.jar"/>
+        <include name="jetty8-server-8.1.3.v20120416.jar"/>
+        <include name="jetty8-servlet-8.1.3.v20120416.jar"/>
+        <include name="jetty8-servlets-8.1.3.v20120416.jar"/>
+        <include name="jetty8-util-8.1.3.v20120416.jar"/>
+        <include name="jetty8-http-8.1.3.v20120416.jar"/>
+        <include name="jetty8-io-8.1.3.v20120416.jar"/>
+        <include name="jetty8-xml-8.1.3.v20120416.jar"/>
+        <include name="jetty8-webapp-8.1.3.v20120416.jar"/>
+        <include name="jetty8-continuation-8.1.3.v20120416.jar"/>
+        <include name="jetty8-security-8.1.3.v20120416.jar"/>
+        <include name="logback-classic-1.0.4.jar"/>
+        <include name="logback-core-1.0.4.jar"/>
+        <include name="slf4j-api-1.6.5.jar"/>
+      </zipgroupfileset>
+      <fileset dir="${classes}"
+               includes="**/*"
+               excludes="**/Test*.class"/>
+      <fileset dir="${config}" includes="jetty.xml" />
+      <zipfileset dir="${config}"
+                  prefix=""
+                  includes="logback.xml"/>
       <zipfileset dir="${config}"
                   prefix="WEB-INF/classes"
                   includes="logback.xml"/>
       <metainf dir="${config}"
                includes="context.xml"/>
+      <manifest>
+        <attribute name="Created-By" value="The Tor Project" />
+        <attribute name="Implementation-Title" value="Onionoo Server"/>
+        <attribute name="Implementation-Version"
+                   value="${release.version}"/>
+        <attribute name="Onionoo-Protocol-Version"
+                   value="${onionoo.protocol.version}" />
+        <attribute name="Main-Class"
+                   value="org.torproject.onionoo.server.ServerMain" />
+      </manifest>
     </war>
   </target>
-  <target name="run" depends="compile">
-    <copy file="logback.xml" todir="${classes}" />
-    <java fork="true"
-          maxmemory="${maxmemory.value}"
-          classname="org.torproject.onionoo.cron.Main">
-      <classpath refid="classpath"/>
-    </java>
+
+  <target name="jar" depends="compile">
+    <jar destfile="${jarfile}"
+         basedir="${classes}">
+      <zipgroupfileset dir="/usr/share/java">
+        <include name="commons-codec-1.6.jar"/>
+        <include name="commons-compress-1.4.1.jar"/>
+        <include name="commons-lang3-3.1.jar"/>
+        <include name="gson-2.1.jar"/>
+        <include name="logback-classic-1.0.4.jar"/>
+        <include name="logback-core-1.0.4.jar"/>
+        <include name="slf4j-api-1.6.5.jar"/>
+      </zipgroupfileset>
+      <zipgroupfileset dir="deps/metrics-lib">
+        <include name="descriptor.jar"/>
+      </zipgroupfileset>
+      <fileset dir="${classes}"
+               excludes="org/torproject/onionoo/server/" />
+      <fileset dir="${config}" includes="logback.xml" />
+      <exclude name="**/Test*.class"/>
+      <manifest>
+        <attribute name="Created-By" value="The Tor Project" />
+        <attribute name="Implementation-Title" value="Onionoo Server"/>
+        <attribute name="Implementation-Version"
+                   value="${release.version}"/>
+        <attribute name="Onionoo-Protocol-Version"
+                   value="${onionoo.protocol.version}" />
+        <attribute name="Main-Class"
+                   value="org.torproject.onionoo.cron.Main" />
+      </manifest>
+    </jar>
   </target>
+
+  <target name="dist" depends="test, war, jar"/>
+
 </project>
 
diff --git a/etc/jetty.xml b/etc/jetty.xml
new file mode 100644
index 0000000..c172902
--- /dev/null
+++ b/etc/jetty.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
+  "http://www.eclipse.org/jetty/configure.dtd">
+
+<Configure id="server" class="org.eclipse.jetty.server.Server" >
+  <Set name="dumpAfterStart">false</Set>
+
+  <Set name="threadPool">
+    <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
+      <Set name="minThreads">25</Set>
+      <Set name="maxThreads">250</Set>
+      <Set name="detailedDump">false</Set>
+    </New>
+  </Set>
+
+  <New id="webAppContext" class="org.eclipse.jetty.webapp.WebAppContext">
+    <Set name="logUrlOnStart">true</Set>
+    <Set name="war">
+      <Call class="java.lang.System" name="getProperty">
+        <Arg>java.class.path</Arg>
+      </Call>
+    </Set>
+  </New>
+
+  <Call name="addConnector">
+    <Arg>
+      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
+        <Set name="port">8080</Set>
+      </New>
+    </Arg>
+  </Call>
+
+  <Set name="handler">
+    <!-- maybe add more handlers (statistics, logging, etc.) later -->
+    <New class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
+      <Call name="addHandler">
+        <Arg>
+          <Ref id="webAppContext"/>
+        </Arg>
+      </Call>
+    </New>
+  </Set>
+
+</Configure>
+
diff --git a/etc/logback.xml b/etc/logback.xml
index 812c7c9..ac41b64 100644
--- a/etc/logback.xml
+++ b/etc/logback.xml
@@ -1,17 +1,25 @@
 <configuration debug="false">
 
-  <!-- don't forget the trailing slash! -->
-  <property name="logfile-base" value="/var/log/tomcat6/" />
+  <!-- a path and a prefix -->
+  <property name="logfile-base" value="${LOGBASE}/onionoo-" />
+
+  <!-- log file names -->
+  <property name="fileall-logname" value="${logfile-base}all" />
+  <property name="fileerr-logname" value="${logfile-base}err" />
+  <property name="filestatistics-logname" value="${logfile-base}statistics" />
+
+  <!-- date pattern -->
   <property name="utc-date-pattern" value="%date{yyyy-MM-dd HH:mm:ss, UTC}" />
 
+  <!-- appender section -->
   <appender name="FILEALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
-    <file>${logfile-base}onionoo-all.log</file>
+    <file>${fileall-logname}.log</file>
     <encoder>
-      <pattern>${utc-date-pattern} %level %logger{25}:%line %msg%n</pattern>
+      <pattern>${utc-date-pattern} %level [runtime: %r] %logger{20}:%line %msg%n</pattern>
     </encoder>
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
       <!-- rollover daily -->
-      <FileNamePattern>${logfile-base}onionoo-all.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+      <FileNamePattern>${fileall-logname}.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
       <maxHistory>10</maxHistory>
       <timeBasedFileNamingAndTriggeringPolicy
             class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
@@ -22,36 +30,53 @@
   </appender>
 
   <appender name="FILEERR" class="ch.qos.logback.core.FileAppender">
-    <file>${logfile-base}onionoo-err.log</file>
+    <file>${fileerr-logname}.log</file>
     <encoder>
-      <pattern>%date %level %logger{30}(%line): %msg%n</pattern>
+      <pattern>${utc-date-pattern} %level %logger{30}(%line): %msg%n</pattern>
     </encoder>
+
+    <!-- ERROR or worse -->
     <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
       <level>ERROR</level>
     </filter>
   </appender>
+
   <appender name="FILESTATISTICS" class="ch.qos.logback.core.FileAppender">
-    <file>${logfile-base}onionoo-statistics.log</file>
+    <file>${filestatistics-logname}.log</file>
     <encoder>
-      <pattern>${utc-date-pattern} %msg%n</pattern>
+      <pattern>${utc-date-pattern} [runtime: %r] %msg%n</pattern>
     </encoder>
-    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+
+    <!-- only INFO level -->
+    <filter class="ch.qos.logback.classic.filter.LevelFilter">
       <level>INFO</level>
+      <onMatch>ACCEPT</onMatch>
+      <onMismatch>DENY</onMismatch>
     </filter>
   </appender>
 
+  <!-- logger section -->
   <logger name="org.torproject" >
     <appender-ref ref="FILEERR" />
   </logger>
+
+  <logger name="org.eclipse" level="INFO" />
+
+  <logger name="org.torproject.onionoo.cron.Main" >
+    <appender-ref ref="FILESTATISTICS" />
+  </logger>
+
   <logger name="org.torproject.onionoo.server.PerformanceMetrics" >
     <appender-ref ref="FILESTATISTICS" />
   </logger>
-  <logger name="statistics"  >
+
+  <logger name="statistics" >
     <appender-ref ref="FILESTATISTICS" />
   </logger>
 
   <root level="ALL">
     <appender-ref ref="FILEALL" />
   </root>
+
 </configuration>
 
diff --git a/etc/web.xml.template b/etc/web.xml.template
index 2c0b280..cefdfae 100644
--- a/etc/web.xml.template
+++ b/etc/web.xml.template
@@ -51,5 +51,28 @@
       org.torproject.onionoo.server.NodeIndexer
     </listener-class>
   </listener>
+
+  <filter>
+    <filter-name>GzipFilter</filter-name>
+    <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
+    <init-param>
+      <param-name>mimeTypes</param-name>
+      <param-value>text/html,text/xml,text/plain,application/json</param-value>
+    </init-param>
+    <init-param>
+      <param-name>excludedAgents</param-name>
+      <param-value>gozilla,traviata</param-value>
+    </init-param>
+    <init-param>
+      <param-name>minGzipSize</param-name>
+      <param-value>2048</param-value>
+    </init-param>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>GzipFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+
 </web-app>
 
diff --git a/logback.xml b/logback.xml
deleted file mode 100644
index fcf278c..0000000
--- a/logback.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<configuration debug="false">
-
-  <!-- don't forget the trailing slash! -->
-  <property name="logfile-base" value="/srv/onionoo.torproject.org/onionoo/" />
-  <property name="utc-date-pattern" value="%date{ISO8601, UTC}" />
-
-  <appender name="FILEALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
-    <file>${logfile-base}onionoo-all.log</file>
-    <encoder>
-      <pattern>${utc-date-pattern} %level %logger{20}:%line %msg%n</pattern>
-    </encoder>
-    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-      <!-- rollover daily -->
-      <FileNamePattern>${logfile-base}onionoo-all.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
-      <maxHistory>10</maxHistory>
-      <timeBasedFileNamingAndTriggeringPolicy
-            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
-        <!-- or whenever the file size reaches 1MB -->
-        <maxFileSize>1MB</maxFileSize>
-      </timeBasedFileNamingAndTriggeringPolicy>
-    </rollingPolicy>
-  </appender>
-
-  <appender name="FILEERR" class="ch.qos.logback.core.FileAppender">
-    <file>${logfile-base}onionoo-err.log</file>
-    <encoder>
-      <pattern>${utc-date-pattern} %level %logger{20}:%line %msg%n</pattern>
-    </encoder>
-
-    <!-- ERROR or worse -->
-    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
-      <level>ERROR</level>
-    </filter>
-  </appender>
-
-  <appender name="FILESTATISTICS" class="ch.qos.logback.core.FileAppender">
-    <file>${logfile-base}onionoo-statistics.log</file>
-    <encoder>
-      <pattern>${utc-date-pattern} %msg%n</pattern>
-    </encoder>
-
-    <!-- only INFO level -->
-    <filter class="ch.qos.logback.classic.filter.LevelFilter">
-      <level>INFO</level>
-      <onMatch>ACCEPT</onMatch>
-      <onMismatch>DENY</onMismatch>
-    </filter>
-  </appender>
-
-  <logger name="org.torproject" >
-    <appender-ref ref="FILEERR" />
-  </logger>
-  <logger name="org.torproject.onionoo.cron.Main" >
-    <appender-ref ref="FILESTATISTICS" />
-  </logger>
-
-  <!-- a named logger -->
-  <logger name="statistics" >
-    <appender-ref ref="FILESTATISTICS" />
-  </logger>
-
-  <root level="ALL">
-    <appender-ref ref="FILEALL" />
-  </root>
-</configuration>
-
diff --git a/src/main/java/org/torproject/onionoo/server/ServerMain.java b/src/main/java/org/torproject/onionoo/server/ServerMain.java
new file mode 100644
index 0000000..d109a32
--- /dev/null
+++ b/src/main/java/org/torproject/onionoo/server/ServerMain.java
@@ -0,0 +1,31 @@
+/* Copyright 2014 The Tor Project
+ * See LICENSE for licensing information */
+package org.torproject.onionoo.server;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.xml.XmlConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ServerMain {
+
+  private static final Logger log = LoggerFactory.getLogger(
+      ServerMain.class);
+
+  public static void main(String[] args) {
+    try {
+      Resource onionooXml = Resource.newSystemResource("jetty.xml");
+      log.info("Reading configuration from '" + onionooXml + "'.");
+      XmlConfiguration configuration = new XmlConfiguration(
+          onionooXml.getInputStream());
+      Server server = (Server) configuration.configure();
+      server.start();
+      server.join();
+    } catch (Exception ex) {
+      log.error("Exiting, because of: " + ex.getMessage(), ex);
+      System.exit(1);
+    }
+  }
+}
+
diff --git a/vagrant/bootstrap.sh b/vagrant/bootstrap.sh
index 08d0ac5..ad4507a 100644
--- a/vagrant/bootstrap.sh
+++ b/vagrant/bootstrap.sh
@@ -25,9 +25,6 @@ ln -s /vagrant/etc
 ln -s /vagrant/geoip
 ln -s /vagrant/src
 ln -s /vagrant/web
-ln -s /vagrant/logback.xml
-ln -s /srv/onionoo.torproject.org/onionoo/onionoo.war \
-/var/lib/tomcat6/webapps/onionoo.war
 chown -R vagrant:vagrant /srv/onionoo.torproject.org/
 
 echo "Done provisioning."



More information about the tor-commits mailing list