From ce7d687205fc921c378fcda8e2650dd5a3ef7124 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Wed, 8 Sep 2021 15:07:47 -0400 Subject: [PATCH] Add a shutdown monitor that publishes shutdown state as a metric --- .../textsecuregcm/WhisperServerService.java | 2 ++ .../metrics/ApplicationShutdownMonitor.java | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 service/src/main/java/org/whispersystems/textsecuregcm/metrics/ApplicationShutdownMonitor.java diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index cf89c3d5f..4719f6956 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -113,6 +113,7 @@ import org.whispersystems.textsecuregcm.mappers.RateLimitChallengeExceptionMappe import org.whispersystems.textsecuregcm.mappers.RateLimitExceededExceptionMapper; import org.whispersystems.textsecuregcm.mappers.RetryLaterExceptionMapper; import org.whispersystems.textsecuregcm.mappers.ServerRejectedExceptionMapper; +import org.whispersystems.textsecuregcm.metrics.ApplicationShutdownMonitor; import org.whispersystems.textsecuregcm.metrics.BufferPoolGauges; import org.whispersystems.textsecuregcm.metrics.CpuUsageGauge; import org.whispersystems.textsecuregcm.metrics.FileDescriptorGauge; @@ -506,6 +507,7 @@ public class WhisperServerService extends Application b.get() ? 1 : 0); + } + + @Override + public void start() throws Exception { + shuttingDown.set(false); + } + + @Override + public void stop() throws Exception { + shuttingDown.set(true); + } +}