With sbt it is possible to do ~run to recompile and run the program when the source changes. However once an ActorSystem is created it does not work anymore.
When the system is shutdown it works, but I don't want to shutdown the system.
import akka.actor.ActorSystem
object Test {
def main(args: Array[String]) : Unit = {
val system = ActorSystem()
// if this line is removed, source code detection is disabled
system.shutdown()
}
}
Is there any workaround ?
You have to remember that SBTs ~run by itself is not hot-reloading, it is simply "once the process finishes, run it again please". Akka's thread-pools are non-daemonic, which means that until the ActorSystem is "alive" the program will not terminate, thus SBT's ~run won't trigger again.
Instead you might want to look into the sbt-revolver SBT plugin, which can do what you're looking for (including for Akka based apps).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With