List<JavaCommand> createCommands(Props props) {
List<JavaCommand> commands = new ArrayList<JavaCommand>();
File homeDir = props.nonNullValueAsFile(ProcessConstants.PATH_HOME);
File tempDir = props.nonNullValueAsFile(ProcessConstants.PATH_TEMP);
JavaCommand elasticsearch = new JavaCommand("search");
elasticsearch
.setWorkDir(homeDir)
.addJavaOptions("-Djava.awt.headless=true")
.addJavaOptions(props.nonNullValue(ProcessConstants.SEARCH_JAVA_OPTS))
.addJavaOptions(props.nonNullValue(ProcessConstants.SEARCH_JAVA_ADDITIONAL_OPTS))
.setTempDir(tempDir.getAbsoluteFile())
.setClassName("org.sonar.search.SearchServer")
.setArguments(props.rawProperties())
.addClasspath("./lib/common/*")
.addClasspath("./lib/search/*");
commands.add(elasticsearch);
// do not yet start SQ on elasticsearch slaves
if (StringUtils.isBlank(props.value(ProcessConstants.CLUSTER_MASTER_HOST))) {
JavaCommand webServer = new JavaCommand("web")
.setWorkDir(homeDir)
.addJavaOptions("-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false")
.addJavaOptions(props.nonNullValue(ProcessConstants.WEB_JAVA_OPTS))
.addJavaOptions(props.nonNullValue(ProcessConstants.WEB_JAVA_ADDITIONAL_OPTS))
.setTempDir(tempDir.getAbsoluteFile())
// required for logback tomcat valve
.setEnvVariable(ProcessConstants.PATH_LOGS, props.nonNullValue(ProcessConstants.PATH_LOGS))
.setClassName("org.sonar.server.app.WebServer")
.setArguments(props.rawProperties())
.addClasspath("./lib/common/*")
.addClasspath("./lib/server/*");
String driverPath = props.value(ProcessConstants.JDBC_DRIVER_PATH);
if (driverPath != null) {
webServer.addClasspath(driverPath);
}
commands.add(webServer);
}
return commands;
}