adding fork := true for backend server interrupts

without it app starts in same jvm and we're told that Ctrl+C will not
always kill the Ember server:

https://typelevel.org/cats-effect/docs/2.x/datatypes/ioapp
WARNING: If you run your IOApp program from sbt, you may observe cancellation and resource releasing is not happening. This is due to sbt, by default, running programs in the same JVM as sbt, so when your program is canceled sbt avoids stopping its own JVM. To properly allow cancellation, ensure your progam is forked into its own JVM via a setting like fork := true in your sbt configuration.
This commit is contained in:
efim 2023-04-23 23:35:45 +04:00
parent 77b34a2ca7
commit 8716385ea1
3 changed files with 4 additions and 3 deletions

View File

@ -6,9 +6,9 @@ import com.comcast.ip4s._
import org.http4s.ember.server._
import fs2._
object BackendApp extends IOApp.Simple {
object BackendApp extends IOApp {
override def run: IO[Unit] = {
override def run(args: List[String]): IO[ExitCode] = {
val host = host"0.0.0.0"
val port = port"8080"

View File

@ -26,7 +26,7 @@ object MyHttpService {
val send: Stream[IO, WebSocketFrame] =
Stream
.emits(TestModels.testChangesList)
.covary[IO].metered(2.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
.covary[IO].metered(1.second).map(state => WebSocketFrame.Text(state.asJson.noSpaces))
val receive: Pipe[IO, WebSocketFrame, Unit] = _.evalMap {
case WebSocketFrame.Text(text, _) => Sync[IO].delay(println(text))

View File

@ -44,6 +44,7 @@ lazy val backend = project
.in(file("backend"))
.settings(
commonSettings,
fork := true,
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-ember-client" % http4sVersion,
"org.http4s" %% "http4s-ember-server" % http4sVersion,