Skip to content

Commit

Permalink
Add shutdown timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Baccata committed Sep 8, 2023
1 parent 6bf1de0 commit f0852fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/g8/src/main/scala/com/example/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.http4s.ember.server._
import org.http4s._
import com.comcast.ip4s._
import smithy4s.http4s.SimpleRestJsonBuilder
import scala.concurrent.duration._

object HelloWorldImpl extends HelloWorldService[IO] {
def hello(name: String, town: Option[String]): IO[Greeting] = IO.pure {
Expand Down Expand Up @@ -42,11 +43,11 @@ object Main extends IOApp.Simple {
.withPort(thePort)
.withHost(theHost)
.withHttpApp(routes.orNotFound)
.withShutdownTimeout(1.second)
.build
.productL(IO.println(message).toResource)
}
.useForever
.race(IO.readLine)
.surround(IO.readLine)
.void
.guarantee(IO.println("Goodbye!"))

Expand Down

0 comments on commit f0852fa

Please sign in to comment.