Skip to content

Commit

Permalink
Mark redis subscriber as daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
dentmaged committed Apr 9, 2022
1 parent 7b7f2c9 commit 8b31dcb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/rip/bolt/nerve/redis/RedisManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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!");
Expand All @@ -98,6 +96,8 @@ public void onMessage(String channel, String message) {
}
}
});
this.subscriberThread.setDaemon(true);
this.subscriberThread.start();
}

}

0 comments on commit 8b31dcb

Please sign in to comment.