From e1617e328058de7152f213637919369f21b375ff Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 25 Oct 2020 21:47:22 +0100 Subject: [PATCH] Added a graceful shutdown Signed-off-by: Louis Vallat --- src/main/java/xyz/vallat/louis/MovieQuoteBot.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/xyz/vallat/louis/MovieQuoteBot.java b/src/main/java/xyz/vallat/louis/MovieQuoteBot.java index d2d8a5c..4aacf7e 100644 --- a/src/main/java/xyz/vallat/louis/MovieQuoteBot.java +++ b/src/main/java/xyz/vallat/louis/MovieQuoteBot.java @@ -19,6 +19,8 @@ public class MovieQuoteBot { public static final String DISCORD_TOKEN_ENVIRONMENT = "DISCORD_TOKEN"; public static final String PREFIX = "!"; + public static final String VERSION = "0.1-SNAPSHOT"; + private static final Logger logger = LoggerFactory.getLogger(MovieQuoteBot.class.getCanonicalName()); private static final Map commands = new HashMap<>(); @@ -51,6 +53,8 @@ public class MovieQuoteBot { .next())) .subscribe(); + Runtime.getRuntime().addShutdownHook(new Thread(() -> logger.info("Received shut down signal. Bye!"))); + client.onDisconnect().block(); }