From ec87bf57372195846e4249857db7d59bf6468e8b Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Thu, 20 Oct 2022 22:38:37 -0400 Subject: [PATCH] refactor: exit process if server fails to start --- .../core/serviceframework/PlatformService.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/platform-service-framework/src/main/java/org/hypertrace/core/serviceframework/PlatformService.java b/platform-service-framework/src/main/java/org/hypertrace/core/serviceframework/PlatformService.java index 89d4f5f..e0a7c91 100644 --- a/platform-service-framework/src/main/java/org/hypertrace/core/serviceframework/PlatformService.java +++ b/platform-service-framework/src/main/java/org/hypertrace/core/serviceframework/PlatformService.java @@ -148,6 +148,8 @@ public void start() { adminServer.join(); } catch (Exception e) { LOGGER.error("Failed to start service servlet."); + this.shutdown(); + System.exit(1); } } @@ -175,12 +177,6 @@ public void shutdown() { } catch (Exception ex) { LOGGER.error("Error stopping admin server"); } - if (getServiceState() != State.STARTED) { - LOGGER.info( - "Service - {} is at state: {}. Expecting state: STARTED. Skipping shutdown...", - getServiceName(), getServiceState()); - return; - } LOGGER.info("Trying to shutdown service - {}...", getServiceName()); serviceLifecycle.setState(State.STOPPING); doStop(); @@ -189,5 +185,4 @@ public void shutdown() { PlatformMetricsRegistry.stop(); LOGGER.info("Service - {} is shutdown.", getServiceName()); } - }