How to develop with Akka and sbt?

Development using sbt is unlikely to use the ~run command to say that sbt pickup is changing the code. It is very comfortable.

Now I will play a little with akka . Is there a way to return the default behavior of sbt when ctrl + D stops the application and the code loads on the fly?

Here is an example application:

 object Main extends App { println("Starting actors...") val system = ActorSystem("MySystem") val myActor = system.actorOf(Props[Actors.MyActor], name = "myActor") myActor ! "test" // system.shutdown() } object Actors { class MyActor extends Actor { val log = Logging(context.system, this) def receive = { case "test" => log.info("received test") case _ => log.info("received something else") } } } 

In such cases, the run and ~run commands do not interrupt ctrl + D and do not reload the code when changing. Only ctrl + C to stop all sbt. Since I understand that in the game environment there is some solution for this, because it looks like it stops the acting system on ctrl + D in ~run mode

+6
source share
1 answer

You can try JRebel . You can get a free license for Scala development . Worked for me very well, especially with sbt. Sbt compiles classes, the running Scala application with JRebel loads the newly compiled classes on the fly in the running application without rebooting.

The file my build.sbt has the following data:

 javaOptions ++=Seq("-javaagent:/path/to/jrebel.jar","-Drebel.log=true","-Drebel.log.file=/path/to/jrebel.log") fork := true 

I have two sbt instances. One runs the program, the other compiles all classes when a change is detected ( ~compile ).

+4
source

Source: https://habr.com/ru/post/947925/


All Articles