commit 14f6192ec88971dbd42ad1cc59e271c029a5646e Author: iwakeh iwakeh@torproject.org Date: Tue Aug 22 07:41:02 2017 +0000
Add system property for all paths.
The system property is 'onionoo.basedir'. If not set, backwards compatible defaults apply. Implements task-14201. --- CHANGELOG.md | 4 ++++ src/main/java/org/torproject/onionoo/cron/Main.java | 3 +-- src/main/java/org/torproject/onionoo/server/NodeIndexer.java | 7 +++---- src/main/resources/web.xml | 5 ----- 4 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md index e028dd1..9538287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ - Switch from our own CollecTor downloader to metrics-lib's DescriptorCollector.
+ * Minor changes + - Add a new Java property "onionoo.basedir" to re-configure the + base directory used by the web server component. +
# Changes in version 4.0-1.3.0 - 2017-08-04
diff --git a/src/main/java/org/torproject/onionoo/cron/Main.java b/src/main/java/org/torproject/onionoo/cron/Main.java index 685da35..f6f7099 100644 --- a/src/main/java/org/torproject/onionoo/cron/Main.java +++ b/src/main/java/org/torproject/onionoo/cron/Main.java @@ -22,8 +22,7 @@ import java.util.concurrent.TimeUnit; /* Update search data and status data files. */ public class Main implements Runnable {
- private Main() { - } + private Main() {}
private Logger log = LoggerFactory.getLogger(Main.class);
diff --git a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java index 7ed9ea6..db13ed9 100644 --- a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java +++ b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java @@ -20,7 +20,6 @@ import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap;
-import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener;
@@ -31,11 +30,11 @@ public class NodeIndexer implements ServletContextListener, Runnable {
@Override public void contextInitialized(ServletContextEvent contextEvent) { - ServletContext servletContext = contextEvent.getServletContext(); - File outDir = new File(servletContext.getInitParameter("outDir")); + File outDir = new File(System.getProperty("onionoo.basedir", + "/srv/onionoo.torproject.org/onionoo"), "out"); if (!outDir.exists() || !outDir.isDirectory()) { log.error("\n\n\tOut-dir not found! Expected directory: " + outDir - + "\n\tVerify the configuration in ./etc/web.xml.template"); + + "\n\tSet system property 'onionoo.basedir'."); System.exit(1); } DocumentStore documentStore = DocumentStoreFactory.getDocumentStore(); diff --git a/src/main/resources/web.xml b/src/main/resources/web.xml index cefdfae..da1431b 100644 --- a/src/main/resources/web.xml +++ b/src/main/resources/web.xml @@ -41,11 +41,6 @@ <url-pattern>/uptime</url-pattern> </servlet-mapping>
- <context-param> - <param-name>outDir</param-name> - <param-value>/srv/onionoo.torproject.org/onionoo/out/</param-value> - </context-param> - <listener> <listener-class> org.torproject.onionoo.server.NodeIndexer
tor-commits@lists.torproject.org