Define gerrit.replicateOnStartup to control replication
If this variable is set to false, we won't replicate to the remote peers upon server startup. This may be useful if a site restarts their server multiple times per day and has a very big replication URL set, or has many projects. Bug: issue 685 Change-Id: I4b4d1b8621e508ad15fd13205a7f34880b839467 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -797,6 +797,11 @@ By default unset, as the git daemon must be configured externally
|
||||
by the system administrator, and might not even be running on the
|
||||
same host as Gerrit.
|
||||
|
||||
[[gerrit.replicateOnStartup]]gerrit.replicateOnStartup::
|
||||
+
|
||||
If true, replicates to all remotes on startup to ensure they are
|
||||
in-sync with this server. By default, true.
|
||||
|
||||
[[gitweb]]Section gitweb
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.google.gerrit.server.git.PushAllProjectsOp;
|
||||
import com.google.gerrit.server.git.ReloadSubmitQueueOp;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/** Configuration for a master node in a cluster of servers. */
|
||||
@@ -32,17 +34,24 @@ public class MasterNodeStartup extends LifecycleModule {
|
||||
static class OnStart implements LifecycleListener {
|
||||
private final PushAllProjectsOp.Factory pushAll;
|
||||
private final ReloadSubmitQueueOp.Factory submit;
|
||||
private final boolean replicateOnStartup;
|
||||
|
||||
@Inject
|
||||
OnStart(final PushAllProjectsOp.Factory pushAll,
|
||||
final ReloadSubmitQueueOp.Factory submit) {
|
||||
final ReloadSubmitQueueOp.Factory submit,
|
||||
final @GerritServerConfig Config cfg) {
|
||||
this.pushAll = pushAll;
|
||||
this.submit = submit;
|
||||
|
||||
replicateOnStartup = cfg.getBoolean("gerrit", "replicateOnStartup", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
pushAll.create(null).start(30, TimeUnit.SECONDS);
|
||||
if (replicateOnStartup) {
|
||||
pushAll.create(null).start(30, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
submit.create().start(15, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user