commit 87d17a4207d62b46f25343c181fef968a09789ad Author: iwakeh iwakeh@torproject.org Date: Sat Aug 13 15:19:46 2016 +0200
Implements task-19895: CollecTor exits after running all activated modules in run-once mode.
Scheduler threads are now daemon threads and the config file is not watched when RunOnce is true. --- src/main/java/org/torproject/collector/conf/Configuration.java | 3 +++ src/main/java/org/torproject/collector/cron/Scheduler.java | 1 + 2 files changed, 4 insertions(+)
diff --git a/src/main/java/org/torproject/collector/conf/Configuration.java b/src/main/java/org/torproject/collector/conf/Configuration.java index e55393c..4bab136 100644 --- a/src/main/java/org/torproject/collector/conf/Configuration.java +++ b/src/main/java/org/torproject/collector/conf/Configuration.java @@ -55,6 +55,9 @@ public class Configuration extends Observable implements Cloneable { throw new ConfigurationException("Cannot watch configuration file. " + "Reason: " + e.getMessage(), e); } + if (this.getBool(Key.RunOnce)) { // no need to watch + return; + } this.scheduler.scheduleAtFixedRate(new Runnable() { public void run() { logger.trace("Check configuration file."); diff --git a/src/main/java/org/torproject/collector/cron/Scheduler.java b/src/main/java/org/torproject/collector/cron/Scheduler.java index 6c7b6dd..78789f4 100644 --- a/src/main/java/org/torproject/collector/cron/Scheduler.java +++ b/src/main/java/org/torproject/collector/cron/Scheduler.java @@ -125,6 +125,7 @@ public final class Scheduler implements ThreadFactory { @Override public Thread newThread(Runnable runner) { Thread newThread = threads.newThread(runner); + newThread.setDaemon(true); newThread.setName("CollecTor-Scheduled-Thread-" + ++currentThreadNo); logger.info("New Thread created: " + newThread.getName()); return newThread;
tor-commits@lists.torproject.org