aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2020-12-14 16:15:20 -0600
committersonartech <sonartech@sonarsource.com>2021-01-05 20:15:14 +0000
commit80c2a910e268532d42511d580c695a7b281054df (patch)
treec051c158aad3daa8e61b154e22d81244084c721f /server/sonar-webserver
parent8ab6570b7c2c7b707a99247492a28b5e540efb0d (diff)
downloadsonarqube-80c2a910e268532d42511d580c695a7b281054df.tar.gz
sonarqube-80c2a910e268532d42511d580c695a7b281054df.zip
SONAR-12786 Improve startup error message when the TCP port is already taken
Diffstat (limited to 'server/sonar-webserver')
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java b/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
index d0b0d4f74d0..e7bdc1d237f 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
@@ -19,12 +19,15 @@
*/
package org.sonar.server.app;
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
import com.google.common.base.Throwables;
import java.io.File;
import java.util.concurrent.CountDownLatch;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
+import org.slf4j.LoggerFactory;
import org.sonar.api.utils.log.Loggers;
import org.sonar.process.Props;
@@ -63,7 +66,11 @@ class EmbeddedTomcat {
TomcatConnectors.configure(tomcat, props);
webappContext = new TomcatContexts().configure(tomcat, props);
try {
+ // let Tomcat temporarily log errors at start up - for example, port in use
+ Logger logger = (Logger) LoggerFactory.getLogger("org.apache.catalina.core.StandardService");
+ logger.setLevel(Level.ERROR);
tomcat.start();
+ logger.setLevel(Level.OFF);
new TomcatStartupLogs(Loggers.get(getClass())).log(tomcat);
} catch (LifecycleException e) {
Loggers.get(EmbeddedTomcat.class).error("Fail to start web server", e);