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:
@@ -1680,6 +1680,22 @@ auto-detected and one thread per CPU is used, per client request.
|
||||
By default, 1.
|
||||
|
||||
|
||||
[[plugins]]Section plugins
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
[[plugins.checkFrequency]]plugins.checkFrequency::
|
||||
+
|
||||
How often plugins should be examined for new plugins to load, removed
|
||||
plugins to be unloaded, or updated plugins to be reloaded. Values can
|
||||
be specified using standard time unit abbreviations ('ms', 'sec',
|
||||
'min', etc.).
|
||||
+
|
||||
If set to 0, automatic plugin reloading is disabled. Administrators
|
||||
may force reloading with link:cmd-plugin.html[gerrit plugin reload].
|
||||
+
|
||||
Default is 1 minute.
|
||||
|
||||
|
||||
[[receive]]Section receive
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
This section is used to set who can execute the 'receive-pack' and
|
||||
|
@@ -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()) {
|
||||
|
Reference in New Issue
Block a user