Allow plugins.checkFrequency = 0 to disable scanner

Production systems might not want to scan for plugins, and instead
rely on system administrators to invoke `gerrit plugin reload` or
`gerrit plugin install` to make explicit plugin changes. Disable the
background scanning thread when the check frequency is set to 0 or any
negative value.

Change-Id: Ib0c1b40db51c960650099e5ae84bda6aebbc572e
This commit is contained in:
Shawn O. Pearce
2012-05-09 14:24:25 -07:00
parent 67f7952621
commit 5ad16ea1a1
2 changed files with 31 additions and 7 deletions

View File

@@ -77,11 +77,15 @@ public class PluginLoader implements LifecycleListener {
broken = Maps.newHashMap();
cleanupQueue = new ReferenceQueue<ClassLoader>();
cleanupHandles = Maps.newConcurrentMap();
scanner = new PluginScannerThread(
this,
ConfigUtil.getTimeUnit(cfg,
"plugins", null, "checkFrequency",
TimeUnit.MINUTES.toMillis(1), TimeUnit.MILLISECONDS));
long checkFrequency = ConfigUtil.getTimeUnit(cfg,
"plugins", null, "checkFrequency",
TimeUnit.MINUTES.toMillis(1), TimeUnit.MILLISECONDS);
if (checkFrequency > 0) {
scanner = new PluginScannerThread(this, checkFrequency);
} else {
scanner = null;
}
}
public synchronized List<Plugin> getPlugins() {
@@ -182,12 +186,16 @@ public class PluginLoader implements LifecycleListener {
public synchronized void start() {
log.info("Loading plugins from " + pluginsDir.getAbsolutePath());
rescan(false);
scanner.start();
if (scanner != null) {
scanner.start();
}
}
@Override
public void stop() {
scanner.end();
if (scanner != null) {
scanner.end();
}
synchronized (this) {
boolean clean = !running.isEmpty();
for (Plugin p : running.values()) {