Skip to content

Instantly share code, notes, and snippets.

@novakov-alexey-zz
Created November 1, 2018 12:53
Show Gist options
  • Save novakov-alexey-zz/161bac2d0d74688784802872430d0ae5 to your computer and use it in GitHub Desktop.
Save novakov-alexey-zz/161bac2d0d74688784802872430d0ae5 to your computer and use it in GitHub Desktop.
object Main extends App with StrictLogging {
implicit val system: ActorSystem = ActorSystem("crud-service")
implicit val materializer: ActorMaterializer = ActorMaterializer()
implicit val executionContext: ExecutionContext = system.dispatcher
val (server, cfg) = AppConfig.load.fold(e => sys.error(e.toString), identity)
val mod = new Module(true, cfg)
val serverBinding = Http().bindAndHandle(mod.routes, server.host, server.port)
serverBinding.onComplete {
case Success(bound) =>
logger.info("Server launched at http://{}:{}/",
bound.localAddress.getHostString,
bound.localAddress.getPort)
case Failure(e) =>
logger.error("Server could not start!")
e.printStackTrace()
system.terminate()
mod.close()
}
Await.result(system.whenTerminated, Duration.Inf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment