You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
package wow.doge.mygame
|
|
|
|
import scala.concurrent.duration._
|
|
|
|
import _root_.monix.bio.BIOApp
|
|
import _root_.monix.bio.Task
|
|
import _root_.monix.bio.UIO
|
|
import _root_.monix.execution.Scheduler
|
|
import akka.util.Timeout
|
|
import cats.effect.ExitCode
|
|
import cats.effect.Resource
|
|
import cats.implicits._
|
|
import io.odin._
|
|
import io.odin.json.Formatter
|
|
import io.odin.syntax._
|
|
import scalafx.scene.control.TextArea
|
|
import wow.doge.mygame.utils.GenericConsoleStream
|
|
|
|
object Main extends BIOApp with MainModule {
|
|
import java.util.logging.{Logger => JLogger, Level}
|
|
JLogger.getLogger("").setLevel(Level.SEVERE)
|
|
implicit val timeout = Timeout(1.second)
|
|
|
|
override def scheduler: Scheduler = schedulers.async
|
|
|
|
def appResource(consoleStream: GenericConsoleStream[TextArea]) =
|
|
for {
|
|
logger <-
|
|
consoleLogger().withAsync(
|
|
timeWindow = 1.milliseconds,
|
|
maxBufferSize = Some(100)
|
|
) |+|
|
|
fileLogger(
|
|
"application-log-1.log",
|
|
Formatter.json
|
|
).withAsync(timeWindow = 1.milliseconds, maxBufferSize = Some(2000))
|
|
jmeScheduler <- jMESchedulerResource
|
|
// backend <- Resource.make(toIO(HttpClientMonixBackend()))(backend =>
|
|
// toIO(backend.close())
|
|
// )
|
|
actorSystem <- actorSystemResource(logger, schedulers.async)
|
|
_ <- Resource.liftF(
|
|
new MainApp(
|
|
logger,
|
|
jmeScheduler,
|
|
schedulers,
|
|
consoleStream
|
|
)(actorSystem, timeout, actorSystem.scheduler).program
|
|
)
|
|
|
|
} yield ()
|
|
|
|
def run(args: List[String]): UIO[ExitCode] = {
|
|
val consoleStream = GenericConsoleStream.textAreaStream()
|
|
Console.withOut(consoleStream)(
|
|
appResource(consoleStream)
|
|
.use(_ => Task.unit)
|
|
.flatMap(_ => Task(consoleStream.close()))
|
|
.onErrorHandleWith(ex => UIO(ex.printStackTrace()))
|
|
.as(ExitCode.Success)
|
|
)
|
|
}
|
|
}
|