diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-11-10 07:37:07 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-11-10 07:37:07 +0100 |
commit | 56cf7e94818f872fda569945e145cb111afd6e22 (patch) | |
tree | 408a84215d6ef8e7ce5c5cdb25b81117af6a7ce8 | |
parent | a69fbcc94da062adaf04236a3ac15ca01ac4cc52 (diff) | |
download | sonarqube-56cf7e94818f872fda569945e145cb111afd6e22.tar.gz sonarqube-56cf7e94818f872fda569945e145cb111afd6e22.zip |
Improve error handling when server components fail to start
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/platform/Platform.java | 18 | ||||
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/platform/PlatformLifecycleListener.java | 11 |
2 files changed, 14 insertions, 15 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index fbe36cb9d3a..0d77871fa8b 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -109,12 +109,18 @@ public final class Platform { public void start() { if (!started && isUpToDateDatabase()) { - TimeProfiler profiler = new TimeProfiler().start("Start services"); - startCoreComponents(); - startServiceComponents(); - executeStartupTasks(); - started = true; - profiler.stop(); + try { + TimeProfiler profiler = new TimeProfiler().start("Start services"); + startCoreComponents(); + startServiceComponents(); + executeStartupTasks(); + started = true; + profiler.stop(); + } catch (Exception e) { + // full stacktrace is lost by jruby. It must be logged now. + LoggerFactory.getLogger(getClass()).error("Fail to start server", e); + throw new IllegalStateException("Fail to start server", e); + } } } diff --git a/sonar-server/src/main/java/org/sonar/server/platform/PlatformLifecycleListener.java b/sonar-server/src/main/java/org/sonar/server/platform/PlatformLifecycleListener.java index f886c944c6e..1837223ae1b 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/PlatformLifecycleListener.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/PlatformLifecycleListener.java @@ -19,7 +19,6 @@ */ package org.sonar.server.platform; -import org.slf4j.LoggerFactory; import org.sonar.core.config.Logback; import javax.servlet.ServletContextEvent; @@ -30,14 +29,8 @@ public final class PlatformLifecycleListener implements ServletContextListener { public void contextInitialized(ServletContextEvent event) { configureLogback(); - try { - Platform.getInstance().init(event.getServletContext()); - Platform.getInstance().start(); - } catch (Exception e) { - // full stacktrace is lost by jruby-rack. It must be logged now. - LoggerFactory.getLogger(getClass()).error("Fail to start server", e); - throw new IllegalStateException("Fail to start server", e); - } + Platform.getInstance().init(event.getServletContext()); + Platform.getInstance().start(); } public void contextDestroyed(ServletContextEvent event) { |