summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriwakeh <iwakeh@torproject.org>2017-08-22 07:41:02 +0000
committeriwakeh <iwakeh@torproject.org>2017-08-22 07:41:03 +0000
commit0147e58144a1d0c346f0ac7b8904c55c0b7ee374 (patch)
treec9de9b25643f42ccbe73bbf481e6fa25e800e843
parent23bf1292718eac23c4c09daf0c2d10dcda333ca5 (diff)
Add system property for all paths.task-14201
The system property is 'onionoo.basedir'. If not set, backwards compatible defaults apply. Implements task-14201.
-rw-r--r--src/main/java/org/torproject/onionoo/cron/Main.java11
-rw-r--r--src/main/java/org/torproject/onionoo/docs/DocumentStore.java3
-rw-r--r--src/main/java/org/torproject/onionoo/server/NodeIndexer.java5
-rw-r--r--src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java3
-rw-r--r--src/main/java/org/torproject/onionoo/updater/DescriptorSource.java14
-rw-r--r--src/main/resources/web.xml5
6 files changed, 26 insertions, 15 deletions
diff --git a/src/main/java/org/torproject/onionoo/cron/Main.java b/src/main/java/org/torproject/onionoo/cron/Main.java
index 685da35..43016af 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() {/* empty */}
private Logger log = LoggerFactory.getLogger(Main.class);
@@ -94,6 +93,10 @@ public class Main implements Runnable {
+ "output document files, then exit.");
System.err.println(" --help Print out this help message "
+ "and exit.");
+ System.err.println("\nThere is one system property for changing Onionoo's"
+ + " working path. Simply add\n"
+ + "\t-Donionoo.basedir=<set-to-existing-folder>\n"
+ + "to the java start command.");
System.exit(status);
}
@@ -137,7 +140,9 @@ public class Main implements Runnable {
private DocumentStore ds;
- private File outDir = new File("out");
+ private File outDir
+ = new File(System.getProperty("onionoo.basedir",
+ "/srv/onionoo.torproject.org/onionoo"), "out");
private StatusUpdateRunner sur;
diff --git a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
index 56ca406..4bcee4d 100644
--- a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
+++ b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
@@ -42,7 +42,8 @@ public class DocumentStore {
private static Logger log = LoggerFactory.getLogger(
DocumentStore.class);
- private final File statusDir = new File("status");
+ private final File statusDir = new File(System.getProperty("onionoo.basedir",
+ "/srv/onionoo.torproject.org/onionoo"), "status");
private File outDir = null;
diff --git a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
index f6b9510..7403fcb 100644
--- a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
+++ b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
@@ -32,10 +32,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/java/org/torproject/onionoo/updater/DescriptorDownloader.java b/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java
index 1e41f25..c22f1e3 100644
--- a/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java
+++ b/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java
@@ -30,7 +30,8 @@ class DescriptorDownloader {
private String directory;
- private final File inDir = new File("in/recent");
+ private final File inDir = new File(System.getProperty("onionoo.basedir",
+ "/srv/onionoo.torproject.org/onionoo"),"in/recent");
public DescriptorDownloader(DescriptorType descriptorType) {
switch (descriptorType) {
diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java
index 45b40ee..23bf96f 100644
--- a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java
+++ b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java
@@ -22,11 +22,13 @@ public class DescriptorSource {
private static final Logger log = LoggerFactory.getLogger(
DescriptorSource.class);
- private final File inRecentDir = new File("in/recent");
+ private final File inDir;
- private final File inArchiveDir = new File("in/archive");
+ private final File inRecentDir;
- private final File statusDir = new File("status");
+ private final File inArchiveDir;
+
+ private final File statusDir;
private List<DescriptorQueue> descriptorQueues;
@@ -36,6 +38,12 @@ public class DescriptorSource {
public DescriptorSource() {
this.descriptorQueues = new ArrayList<>();
this.descriptorListeners = new HashMap<>();
+ this.inDir = new File(System.getProperty("onionoo.basedir",
+ "/srv/onionoo.torproject.org/onionoo"), "in");
+ this.inDir.mkdirs();
+ this.inRecentDir = new File(inDir, "recent");
+ this.inArchiveDir = new File(inDir, "archive");
+ this.statusDir = new File(inDir, "status");
}
private DescriptorQueue getDescriptorQueue(
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