Fix init from WebAppInitializer when using -Dgerrit.site_path
This fix is mostly useful for those developers who want to deploy/test Gerrit in Tomcat, use the embedded H2 database and have automatic init on deployment. The init of a new site on startup (from WebAppInitializer) was failing when the site was provided via the -Dgerrit.site_path property because we assumed that the database initialization has to be skipped always when running in a servlet container. However, this is only true for the case when using the -Dgerrit.init_path. When Gerrit site is provided via -Dgerrit.site_path then we have to perform database initialization. Change-Id: Id577f391cd888bd71ec8502e8ad2f621cbc3fd80
This commit is contained in:
@@ -57,19 +57,22 @@ import javax.sql.DataSource;
|
||||
public class BaseInit extends SiteProgram {
|
||||
|
||||
private final boolean standalone;
|
||||
private final boolean initDb;
|
||||
|
||||
public BaseInit() {
|
||||
this.standalone = true;
|
||||
this.initDb = true;
|
||||
}
|
||||
|
||||
public BaseInit(File sitePath, boolean standalone) {
|
||||
this(sitePath, null, standalone);
|
||||
public BaseInit(File sitePath, boolean standalone, boolean initDb) {
|
||||
this(sitePath, null, standalone, initDb);
|
||||
}
|
||||
|
||||
public BaseInit(File sitePath, final Provider<DataSource> dsProvider,
|
||||
boolean standalone) {
|
||||
boolean standalone, boolean initDb) {
|
||||
super(sitePath, dsProvider);
|
||||
this.standalone = standalone;
|
||||
this.initDb = initDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +151,7 @@ public class BaseInit extends SiteProgram {
|
||||
final File sitePath = getSitePath();
|
||||
final List<Module> m = new ArrayList<Module>();
|
||||
|
||||
m.add(new InitModule(standalone));
|
||||
m.add(new InitModule(standalone, initDb));
|
||||
m.add(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Init extends BaseInit {
|
||||
}
|
||||
|
||||
public Init(File sitePath) {
|
||||
super(sitePath, true);
|
||||
super(sitePath, true, true);
|
||||
batchMode = true;
|
||||
noAutoStart = true;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,11 @@ import java.lang.annotation.Annotation;
|
||||
public class InitModule extends FactoryModule {
|
||||
|
||||
private final boolean standalone;
|
||||
private final boolean initDb;
|
||||
|
||||
public InitModule(boolean standalone) {
|
||||
public InitModule(boolean standalone, boolean initDb) {
|
||||
this.standalone = standalone;
|
||||
this.initDb = initDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +45,7 @@ public class InitModule extends FactoryModule {
|
||||
step().to(UpgradeFrom2_0_x.class);
|
||||
|
||||
step().to(InitGitManager.class);
|
||||
if (standalone) {
|
||||
if (initDb) {
|
||||
step().to(InitDatabase.class);
|
||||
}
|
||||
step().to(InitIndex.class);
|
||||
|
||||
Reference in New Issue
Block a user