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.

39 lines
1.2 KiB

4 years ago
4 years ago
  1. package nova.monadic_sfx
  2. import scala.concurrent.duration._
  3. import _root_.monix.bio.BIOApp
  4. import _root_.monix.bio.Task
  5. import _root_.monix.bio.UIO
  6. import cats.effect.ExitCode
  7. import cats.effect.Resource
  8. import cats.implicits._
  9. import com.softwaremill.macwire._
  10. import io.odin._
  11. import io.odin.syntax._
  12. import nova.monadic_sfx.executors._
  13. // import nova.monadic_sfx.util.IOUtils._
  14. // import sttp.client.httpclient.monix.HttpClientMonixBackend
  15. object Main extends MainModule with BIOApp {
  16. def appResource(startTime: Long) =
  17. for {
  18. implicit0(logger: Logger[Task]) <-
  19. consoleLogger().withAsync(timeWindow = 1.millis) |+| fileLogger(
  20. "application.log"
  21. ).withAsync()
  22. schedulers = new Schedulers()
  23. // backend <- Resource.make(
  24. // toIO(HttpClientMonixBackend()(schedulers.async))
  25. // )(c => toIO(c.close()))
  26. // actorSystem <- actorSystemResource(logger)
  27. _ <- Resource.liftF(wire[MainApp].program)
  28. } yield ()
  29. override def run(args: List[String]): UIO[ExitCode] =
  30. appResource(System.currentTimeMillis())
  31. .use(_ => Task.unit)
  32. .onErrorHandleWith(ex => UIO(ex.printStackTrace()))
  33. .as(ExitCode.Success)
  34. }