diff options
6 files changed, 36 insertions, 13 deletions
@@ -18,4 +18,6 @@ touch logs/application.log touch logs/search.log touch logs/sonar.log -tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; java -jar lib/sonar-application*.jar" +#tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; java -jar lib/sonar-application*.jar" + +tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; tail -f logs/application.log" diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java index 263e3c6c242..7cecc3001de 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java @@ -130,7 +130,7 @@ public class ProcessWrapper extends Thread { processBuilder.environment().putAll(envProperties); try { - LOGGER.debug("Execute command: {}", StringUtils.join(command, " ")); + LOGGER.info("Starting {} process with command line: {}", getName(), StringUtils.join(command, " ")); process = processBuilder.start(); errorGobbler = new StreamGobbler(process.getErrorStream(), this.getName() + "-ERROR"); outputGobbler = new StreamGobbler(process.getInputStream(), this.getName()); @@ -238,7 +238,7 @@ public class ProcessWrapper extends Thread { JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, null); MBeanServerConnection mBeanServer = jmxConnector.getMBeanServerConnection(); ProcessMXBean bean = JMX.newMBeanProxy(mBeanServer, Process.objectNameFor(processName), ProcessMXBean.class); - LOGGER.info("ProcessWrapper::waitForJMX -- Connected to JMX Server with URL: {}", jmxUrl.toString()); + LOGGER.info("{} process up and running, listening to its state with url: '{}'", getName(), jmxUrl.toString()); return bean; } catch (MalformedURLException e) { throw new IllegalStateException("JMXUrl is not valid", e); @@ -253,6 +253,7 @@ public class ProcessWrapper extends Thread { public void terminate() { if (processMXBean != null) { + LOGGER.info("Stopping {} process", getName()); processMXBean.terminate(); try { this.join(); @@ -260,6 +261,7 @@ public class ProcessWrapper extends Thread { // ignore } processMXBean = null; + LOGGER.info("{} process stopped", getName()); } } diff --git a/server/sonar-search/src/main/resources/logback.xml b/server/sonar-search/src/main/resources/logback.xml index d44b97f9bc8..1800be76f8f 100644 --- a/server/sonar-search/src/main/resources/logback.xml +++ b/server/sonar-search/src/main/resources/logback.xml @@ -29,7 +29,7 @@ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>warn</level> + <level>WARN</level> </filter> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern> diff --git a/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml b/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml index fe7c457ccda..19d87729302 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml +++ b/server/sonar-server/src/main/resources/org/sonar/server/platform/logback.xml @@ -29,7 +29,7 @@ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>warn</level> + <level>WARN</level> </filter> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern> @@ -86,9 +86,15 @@ <level value="INFO"/> </logger> + <!-- LOG level for logback itself --> + <logger name="ch.qos.logback"> + <level value="WARN"/> + </logger> + <root> <level value="INFO"/> <appender-ref ref="LOGFILE"/> + <appender-ref ref="CONSOLE"/> </root> </configuration> diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index 9be3956c795..fc68b9d5e09 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -36,6 +36,10 @@ public class App implements ProcessMXBean { static final String PROCESS_NAME = "SonarQube"; + static final String SONAR_WEB_PROCESS = "web"; + static final String SONAR_SEARCH_PROCESS = "search"; + + private final Installation installation; private Monitor monitor; private ProcessWrapper elasticsearch; @@ -69,10 +73,9 @@ public class App implements ProcessMXBean { } public void start() { - Logger logger = LoggerFactory.getLogger(getClass()); - logger.info("Starting Elasticsearch"); - elasticsearch = new ProcessWrapper("ES") + LOGGER.info("Starting search server"); + elasticsearch = new ProcessWrapper(SONAR_SEARCH_PROCESS) .setWorkDir(installation.homeDir()) .setJmxPort(Integer.parseInt(installation.prop(DefaultSettings.ES_JMX_PORT_KEY))) .addJavaOpts(installation.prop(DefaultSettings.ES_JAVA_OPTS_KEY)) @@ -84,9 +87,10 @@ public class App implements ProcessMXBean { .addClasspath(installation.starPath("lib/search")) .execute(); monitor.registerProcess(elasticsearch); + LOGGER.info("Search server is ready"); - logger.info("Starting HTTP server"); - server = new ProcessWrapper("SQ") + LOGGER.info("Starting web server"); + server = new ProcessWrapper(SONAR_WEB_PROCESS) .setWorkDir(installation.homeDir()) .setJmxPort(Integer.parseInt(installation.prop(DefaultSettings.WEB_JMX_PORT_KEY))) .addJavaOpts(installation.prop(DefaultSettings.WEB_JAVA_OPTS_KEY)) @@ -103,7 +107,8 @@ public class App implements ProcessMXBean { .addClasspath(installation.starPath("lib/server")) .execute(); monitor.registerProcess(server); - logger.info("HTTP server is Ready"); + LOGGER.info("Web server is ready"); + monitor.start(); try { @@ -120,8 +125,6 @@ public class App implements ProcessMXBean { @Override public void terminate() { if (monitor != null) { - Logger logger = LoggerFactory.getLogger(getClass()); - logger.info("Shutting down server"); monitor.interrupt(); monitor = null; if (elasticsearch != null) { @@ -130,6 +133,7 @@ public class App implements ProcessMXBean { if (server != null) { server.terminate(); } + LOGGER.info("Stopping SonarQube main process"); } } diff --git a/sonar-application/src/main/resources/org/sonar/application/logback.xml b/sonar-application/src/main/resources/org/sonar/application/logback.xml index 1dc3bd67875..23f2333d19c 100644 --- a/sonar-application/src/main/resources/org/sonar/application/logback.xml +++ b/sonar-application/src/main/resources/org/sonar/application/logback.xml @@ -36,6 +36,14 @@ </appender> + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern> + %d{yyyy.MM.dd HH:mm:ss} %-5level %msg%n + </pattern> + </encoder> + </appender> + <logger name="console" additivity="false"> <appender-ref ref="CONSOLE"/> </logger> @@ -51,6 +59,7 @@ <root> <level value="INFO"/> <appender-ref ref="CONSOLE"/> + <appender-ref ref="FILE"/> </root> </configuration> |