stop the fishnet redis client
This commit is contained in:
parent
8a8bd842f9
commit
468056dcf2
|
@ -32,7 +32,8 @@ final class Env(
|
|||
analysisRepo: lila.analyse.AnalysisRepo,
|
||||
db: lila.db.Db,
|
||||
asyncCache: lila.memo.AsyncCache.Builder,
|
||||
sink: lila.analyse.Analyser
|
||||
sink: lila.analyse.Analyser,
|
||||
lifecycle: play.api.inject.ApplicationLifecycle
|
||||
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||
|
||||
private val config = appConfig.get[FishnetConfig]("fishnet")(AutoConfig.loader)
|
||||
|
@ -42,7 +43,8 @@ final class Env(
|
|||
private lazy val redis = new FishnetRedis(
|
||||
RedisClient create RedisURI.create(config.redisUri),
|
||||
"fishnet-in",
|
||||
"fishnet-out"
|
||||
"fishnet-out",
|
||||
lifecycle
|
||||
)
|
||||
|
||||
private lazy val clientVersion = new Client.ClientVersion(config.clientMinVersion)
|
||||
|
|
|
@ -3,6 +3,7 @@ package lila.fishnet
|
|||
import chess.format.Uci
|
||||
import io.lettuce.core._
|
||||
import io.lettuce.core.pubsub._
|
||||
import scala.concurrent.Future
|
||||
|
||||
import lila.hub.actorApi.map.Tell
|
||||
import lila.hub.actorApi.round.{ FishnetPlay, FishnetStart }
|
||||
|
@ -11,8 +12,9 @@ import lila.common.Bus
|
|||
final class FishnetRedis(
|
||||
client: RedisClient,
|
||||
chanIn: String,
|
||||
chanOut: String
|
||||
) {
|
||||
chanOut: String,
|
||||
lifecycle: play.api.inject.ApplicationLifecycle
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
val connIn = client.connectPubSub()
|
||||
val connOut = client.connectPubSub()
|
||||
|
@ -35,6 +37,14 @@ final class FishnetRedis(
|
|||
}
|
||||
})
|
||||
|
||||
lifecycle.addStopHook { () =>
|
||||
logger.info("Stopping the Redis pool...")
|
||||
Future {
|
||||
client.shutdown()
|
||||
logger.info("Stopped the Redis pool.")
|
||||
}
|
||||
}
|
||||
|
||||
private def writeWork(work: Work.Move): String =
|
||||
List(
|
||||
work.game.id,
|
||||
|
|
Loading…
Reference in a new issue