aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-start
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-07-11 09:40:54 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-07-11 09:40:54 +0200
commit8e2b3b9e2d74cc948e43c4fd3b0ad26c7668ff5f (patch)
treeb166740e4617beacd3cf91ba1d7a7fd9ac3e44b9 /sonar-start
parent50bdcb2e4bc3fa9e096eb15fb89b6f5853208365 (diff)
downloadsonarqube-8e2b3b9e2d74cc948e43c4fd3b0ad26c7668ff5f.tar.gz
sonarqube-8e2b3b9e2d74cc948e43c4fd3b0ad26c7668ff5f.zip
SONAR-5410 - Added SQ as a wrapped process in sonar-start
Diffstat (limited to 'sonar-start')
-rw-r--r--sonar-start/src/main/java/org/sonar/start/StartServer.java92
1 files changed, 60 insertions, 32 deletions
diff --git a/sonar-start/src/main/java/org/sonar/start/StartServer.java b/sonar-start/src/main/java/org/sonar/start/StartServer.java
index 3062343c563..a48745f30de 100644
--- a/sonar-start/src/main/java/org/sonar/start/StartServer.java
+++ b/sonar-start/src/main/java/org/sonar/start/StartServer.java
@@ -38,41 +38,29 @@ public final class StartServer {
private final static Logger LOGGER = LoggerFactory.getLogger(StartServer.class);
private final Env env;
+ private final ExecutorService executor;
+ private final MonitorService monitor;
+ private final String esPort;
- public StartServer(Env env) {
- this.env = env;
- }
-
- private DatagramSocket systemAvailableSocket() throws IOException {
- return new DatagramSocket(0);
- }
+ private ProcessWrapper elasticsearch;
+ private ProcessWrapper sonarqube;
- public void start() throws IOException {
-
- final ExecutorService executor = Executors.newFixedThreadPool(2);
- final MonitorService monitor = new MonitorService(systemAvailableSocket());
-
- final String esPort = Integer.toString(NetworkUtils.freePort());
-
- //Create the processes
- //final ProcessWrapper sonarQube = new ProcessWrapper("SQ", monitor);
- final ProcessWrapper elasticsearch = new ProcessWrapper(
- "org.sonar.search.ElasticSearch",
- new String[]{env.rootDir().getAbsolutePath() + "/lib/search/sonar-search-4.5-SNAPSHOT.jar"},
- ImmutableMap.of(
- "esPort",esPort,
- "esHome", env.rootDir().getAbsolutePath()),
- "ES", monitor.getMonitoringPort());
-
- //Register processes to monitor
- monitor.register(elasticsearch);
+ public StartServer(Env env) throws IOException {
+ this.env = env;
+ this.executor = Executors.newFixedThreadPool(2);
+ this.monitor = new MonitorService(systemAvailableSocket());
+ this.esPort = Integer.toString(NetworkUtils.freePort());
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
LOGGER.info("Shutting down sonar Node");
- //sonarQube.shutdown();
- elasticsearch.shutdown();
+ if (elasticsearch != null) {
+ elasticsearch.shutdown();
+ }
+ if (sonarqube != null) {
+ sonarqube.shutdown();
+ }
executor.shutdown();
try {
executor.awaitTermination(10L, TimeUnit.SECONDS);
@@ -81,11 +69,19 @@ public final class StartServer {
}
}
});
+ }
- // Start our processes
- LOGGER.info("Starting Child processes...");
- executor.submit(elasticsearch);
- //executor.submit(sonarQube);
+ private DatagramSocket systemAvailableSocket() throws IOException {
+ return new DatagramSocket(0);
+ }
+
+ public void start() {
+
+ // Start ES
+ this.startES();
+
+ // Start SQ
+ this.startSQ();
// And monitor the activity
monitor.run();
@@ -93,6 +89,38 @@ public final class StartServer {
// If monitor is finished, we're done. Cleanup
executor.shutdownNow();
+
+ }
+
+ private void registerProcess(ProcessWrapper process) {
+ //Register processes to monitor
+ monitor.register(process);
+
+ // Start our processes
+ LOGGER.info("Starting Child processes...");
+ executor.submit(process);
+ }
+
+ private void startSQ() {
+ sonarqube = new ProcessWrapper(
+ "org.sonar.application.StartServer",
+ new String[]{env.rootDir().getAbsolutePath() + "/lib/server/sonar-application-4.5-SNAPSHOT.jar"},
+ ImmutableMap.of("test", "test"),
+ "SQ", monitor.getMonitoringPort());
+
+ registerProcess(sonarqube);
+ }
+
+ private void startES() {
+ elasticsearch = new ProcessWrapper(
+ "org.sonar.search.ElasticSearch",
+ new String[]{env.rootDir().getAbsolutePath() + "/lib/search/sonar-search-4.5-SNAPSHOT.jar"},
+ ImmutableMap.of(
+ "esPort", esPort,
+ "esHome", env.rootDir().getAbsolutePath()),
+ "ES", monitor.getMonitoringPort());
+
+ registerProcess(elasticsearch);
}
public static void main(String... args) throws InterruptedException, IOException, URISyntaxException {