diff --git a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java index 3b44d67edb4..d1cb08163c5 100644 --- a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java +++ b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/ComponentStarter.java @@ -74,6 +74,7 @@ public static CompletableFuture startComponent(LifecycleComponent componen component.setExceptionHandler((t, e) -> { log.error("Triggered exceptionHandler of Component: {} because of Exception in Thread: {}", component.getName(), t, e); + System.err.println(e.getMessage()); // start the shutdown hook when an uncaught exception happen in the lifecycle component. shutdownHookThread.start(); }); diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java index ab074933fff..926aef43241 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java @@ -339,6 +339,7 @@ static int doMain(String[] args) { server = buildAutoRecoveryServer(new BookieConfiguration(conf)); } catch (Exception e) { LOG.error("Failed to build AutoRecovery Server", e); + System.err.println(e.getMessage()); return ExitCode.SERVER_EXCEPTION; } @@ -349,8 +350,10 @@ static int doMain(String[] args) { Thread.currentThread().interrupt(); // the server is interrupted LOG.info("AutoRecovery server is interrupted. Exiting ..."); + System.err.println(ie.getMessage()); } catch (ExecutionException ee) { LOG.error("Error in bookie shutdown", ee.getCause()); + System.err.println(ee.getMessage()); return ExitCode.SERVER_EXCEPTION; } return ExitCode.OK; diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java index 3eff455a840..0f73100c050 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java @@ -222,6 +222,7 @@ static int doMain(String[] args) { server = buildBookieServer(new BookieConfiguration(conf)); } catch (Exception e) { log.error("Failed to build bookie server", e); + System.err.println(e.getMessage()); return ExitCode.SERVER_EXCEPTION; } @@ -232,8 +233,10 @@ static int doMain(String[] args) { Thread.currentThread().interrupt(); // the server is interrupted log.info("Bookie server is interrupted. Exiting ..."); + System.err.println(ie.getMessage()); } catch (ExecutionException ee) { log.error("Error in bookie shutdown", ee.getCause()); + System.err.println(ee.getMessage()); return ExitCode.SERVER_EXCEPTION; } return ExitCode.OK; diff --git a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java index 99e70188a6d..d0888b3b1d2 100644 --- a/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java +++ b/stream/server/src/main/java/org/apache/bookkeeper/stream/server/StorageServer.java @@ -170,6 +170,7 @@ static int doMain(String[] args) { grpcUseHostname); } catch (Exception e) { log.error("Invalid storage configuration", e); + System.err.println(e.getMessage()); return ExitCode.INVALID_CONF.code(); } @@ -181,8 +182,10 @@ static int doMain(String[] args) { // the server is interrupted. Thread.currentThread().interrupt(); log.info("Storage server is interrupted. Exiting ..."); + System.err.println(e.getMessage()); } catch (ExecutionException e) { log.info("Storage server is exiting ..."); + System.err.println(e.getMessage()); } return ExitCode.OK.code(); }