Skip to content

Commit f93a2c8

Browse files
authored
Merge pull request #39 from disneystreaming/shutdown-timeout
Add shutdown timeout
2 parents 6bf1de0 + f0852fa commit f93a2c8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/g8/src/main/scala/com/example/Main.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.http4s.ember.server._
99
import org.http4s._
1010
import com.comcast.ip4s._
1111
import smithy4s.http4s.SimpleRestJsonBuilder
12+
import scala.concurrent.duration._
1213

1314
object HelloWorldImpl extends HelloWorldService[IO] {
1415
def hello(name: String, town: Option[String]): IO[Greeting] = IO.pure {
@@ -42,11 +43,11 @@ object Main extends IOApp.Simple {
4243
.withPort(thePort)
4344
.withHost(theHost)
4445
.withHttpApp(routes.orNotFound)
46+
.withShutdownTimeout(1.second)
4547
.build
4648
.productL(IO.println(message).toResource)
4749
}
48-
.useForever
49-
.race(IO.readLine)
50+
.surround(IO.readLine)
5051
.void
5152
.guarantee(IO.println("Goodbye!"))
5253

0 commit comments

Comments
 (0)