Skip to content

Commit

Permalink
Merge pull request #133 from buildo/api-130-unbind_port_when_program
Browse files Browse the repository at this point in the history
#130: Unbind port when program exit (closes #130)
  • Loading branch information
Emanuele Cardelli authored Jul 25, 2018
2 parents a5a7fe2 + d99a7ca commit d6ca64e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions wiro/serverAkkaHttp/src/main/scala/RPCServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ class HttpRPCServerActor(
case Status.Failure(cause) => logger.error(s"Unable to bind to ${config.host}:${config.port}", cause)
}

Http()
.bindAndHandle(route, config.host, config.port)
.pipeTo(self)
val bindingFuture = Http()
.bindAndHandle(route, config.host, config.port)
.pipeTo(self)

scala.sys.addShutdownHook({
logger.info("Wiro unbinding on exit")
bindingFuture
.flatMap(_.unbind())
})
}

0 comments on commit d6ca64e

Please sign in to comment.