Created
November 1, 2018 12:53
-
-
Save novakov-alexey-zz/161bac2d0d74688784802872430d0ae5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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