From 8716385ea10c510cf5d627138f018bc3b5f3ab99 Mon Sep 17 00:00:00 2001 From: efim Date: Sun, 23 Apr 2023 23:35:45 +0400 Subject: [PATCH] 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. --- .../scala/industries/sunshine/planningpoker/BackendApp.scala | 4 ++-- .../industries/sunshine/planningpoker/MyHttpService.scala | 2 +- build.sbt | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/scala/industries/sunshine/planningpoker/BackendApp.scala b/backend/src/main/scala/industries/sunshine/planningpoker/BackendApp.scala index 7bf6596..98b36a7 100644 --- a/backend/src/main/scala/industries/sunshine/planningpoker/BackendApp.scala +++ b/backend/src/main/scala/industries/sunshine/planningpoker/BackendApp.scala @@ -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" diff --git a/backend/src/main/scala/industries/sunshine/planningpoker/MyHttpService.scala b/backend/src/main/scala/industries/sunshine/planningpoker/MyHttpService.scala index 73cdd42..1745c5a 100644 --- a/backend/src/main/scala/industries/sunshine/planningpoker/MyHttpService.scala +++ b/backend/src/main/scala/industries/sunshine/planningpoker/MyHttpService.scala @@ -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)) diff --git a/build.sbt b/build.sbt index 967f7fd..838f1f6 100644 --- a/build.sbt +++ b/build.sbt @@ -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,