Closed omidb closed 1 year ago
Confirming, thanks for reporting. I've noticed this behavior recently and will take a look.
needs to change to:
def toManaged: ZIO[Scope, Throwable, Server] =
start.as(this).withFinalizer(_ => (this.shutdown *> this.awaitTermination).ignore)
Thanks for the PR @regiskuckaertz . Agree it is better to wait for shutdown before the program moves on, however the user's issue is caused by SBT.
When running in sbt without fork := true
, hitting Ctrl-C
will not make the finalizers run - it makes the main thread exit immediately and all background threads remain running. AFAIK, there is no way for a program to handle this interrupt. To solve the problem, you have to add fork := true
to your sbt settings.
@thesamet ah, I did not catch that part, but indeed that's unrelated to the library. Thanks for merging!
I'm creating very simple server and I'm using sbt and the run command to run the server. I can run my server but after interrupting the execution using ctrl+c, I cannot run the server again. It seems that it's not releasing the resources correctly:
and here is the code:
Should I use a different layer or something?