Extending StreamApp
asks you to provide the stream
def. It has a requestShutdown
parameter.
def stream(args: List[String], requestShutdown: F[Unit]): Stream[F, ExitCode]
I provide the implementation for this and understand that args
is passed in as command line arguments. I'm unsure however, what supplies the requestShutdown
parameter and what I can do with it.
Specifically, I'd like to invoke a graceful shutdown on a Stream[IO, ExitCode]
which is starting a Http4s server (which blocks forever).
It looks like a Signal
is needed and must be set? The underlying stream that I'm trying to 'get at' looks like this:
for {
scheduler <- Scheduler[IO](corePoolSize = 1)
exitCode <- BlazeBuilder[IO]
.bindHttp(port, "0.0.0.0")
.mountService(services(scheduler), "/")
.serve
} yield exitCode
My stream
def is here and StreamAppSpec
from the fs2 project has something in the StreamAppSpec
but I can't work out how I'd adapt it.