feat: Update Dockerfile for multi-platform support and add nginx configuration
This commit is contained in:
45
knockoutwhistweb/app/logic/Gateway.scala
Normal file
45
knockoutwhistweb/app/logic/Gateway.scala
Normal file
@@ -0,0 +1,45 @@
|
||||
package logic
|
||||
|
||||
import de.knockoutwhist.data.Pod
|
||||
import de.knockoutwhist.data.redis.RedisManager
|
||||
import org.apache.pekko.actor.ActorSystem
|
||||
import org.redisson.config.Config
|
||||
import play.api.inject.ApplicationLifecycle
|
||||
|
||||
import java.util.UUID
|
||||
import javax.inject.*
|
||||
import scala.concurrent.ExecutionContext
|
||||
import scala.jdk.CollectionConverters.*
|
||||
|
||||
@Singleton
|
||||
class Gateway @Inject()(
|
||||
lifecycle: ApplicationLifecycle,
|
||||
actorSystem: ActorSystem
|
||||
)(implicit ec: ExecutionContext) {
|
||||
|
||||
val redis: RedisManager = {
|
||||
val config: Config = Config()
|
||||
config.useSingleServer.setAddress("valkey://" + sys.env.getOrElse("VALKEY_HOST", "localhost") + ":" + sys.env.getOrElse("VALKEY_PORT", "6379"))
|
||||
RedisManager(config)
|
||||
}
|
||||
|
||||
redis.continuousSyncPod(() => {
|
||||
createPod()
|
||||
})
|
||||
|
||||
def syncPod(): Unit = {
|
||||
redis.syncPod(createPod())
|
||||
}
|
||||
|
||||
private def createPod(): Pod = {
|
||||
Pod(
|
||||
UUID.randomUUID().toString,
|
||||
PodManager.podName,
|
||||
PodManager.podIp,
|
||||
9000,
|
||||
PodManager.getAllGameIds().asJava,
|
||||
PodManager.allBoundUsers().asJava
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user