Gracefully restart the entire Accra system

How can I gracefully restart the entire acting system? In other words, stop all system participants using gracefulStop (or at least important ones!)

Basically, I want, in fact, to restart the application during the test, without overhead, to launch a new separate JVM each time.

I am using Akka 2.0.5.

+7
source share
2 answers

Whenever you introduce an actor system and it lacks one function, feel free to add another actor to take care of this: in this case, create one actor whose job is to send graceful stop requests to your important actors and wait their completion. This actor can then turn off the acting system, and outside you are awaitTermination . If you created this actor using system.actorOf(Props[Terminator], "terminator") , you can close it with

 system.actorFor("/user/terminator") ! MakeItStop // or whatever message you choose try system.awaitTermination(1.minute) // or however long it may take catch { case _: TimeoutException => system.shutdown() // as a last resort } 
+6
source

If for unit test you can just stop ActorSystem and start a new one.

 val system1 = ActorSystem("system1") system1.shutdown() // This is async and will return before the system actually stops. val system2 = ActorSystem("system2") 

I'm not sure how you can reboot the system (in fact, I'm not sure if this works, but I see no reason for this).

+1
source

All Articles