From 8b31dcb7b81674153cb5442d70d0ecbb5a933542 Mon Sep 17 00:00:00 2001 From: William Jeffcock Date: Sat, 9 Apr 2022 15:41:46 +0100 Subject: [PATCH] Mark redis subscriber as daemon --- src/main/java/rip/bolt/nerve/redis/RedisManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/rip/bolt/nerve/redis/RedisManager.java b/src/main/java/rip/bolt/nerve/redis/RedisManager.java index d982089..f9fed82 100644 --- a/src/main/java/rip/bolt/nerve/redis/RedisManager.java +++ b/src/main/java/rip/bolt/nerve/redis/RedisManager.java @@ -15,12 +15,11 @@ import redis.clients.jedis.exceptions.JedisConnectionException; import rip.bolt.nerve.event.RedisConnectEvent; import rip.bolt.nerve.event.RedisMessageEvent; -import rip.bolt.nerve.utils.Executor; public class RedisManager { private ProxyServer server; - private Executor executor; + private Thread subscriberThread; private RedisConfig config; private Logger logger; @@ -30,12 +29,11 @@ public class RedisManager { private static String[] subscriberChannels = { "queue", "match" }; @Inject - public RedisManager(ProxyServer server, Executor executor, RedisConfig config, Logger logger) { + public RedisManager(ProxyServer server, RedisConfig config, Logger logger) { if (!config.enabled()) return; this.server = server; - this.executor = executor; this.config = config; this.logger = logger; @@ -73,7 +71,7 @@ public boolean connect() { } public void startSubscriberThread() { - executor.async(() -> { + this.subscriberThread = new Thread(() -> { while (!Thread.interrupted() && !pool.isClosed()) { try (Jedis jedis = pool.getResource()) { logger.info("Connected to Redis!"); @@ -98,6 +96,8 @@ public void onMessage(String channel, String message) { } } }); + this.subscriberThread.setDaemon(true); + this.subscriberThread.start(); } }