Exitting system process

Good afternoon,

I am executing multiple processes in an actor system, and I wish for all process to exit, as soon as a System.exit is met ?

Is it possible please, since at the moment when a process hits a System.exit, the other processes keep on running, but I require that every process that was executed during this execution is terminated ?

Thanks a lot and good day :slight_smile:


normally, when you start writing a program using an actor library, you start with a single actor system in a single process. That is, in your main method, you create an actor system and spawn many actors within that one system.

If you go beyond that (say distributed systems, cluster setup etc), the details of how you can coordinate shutdown will depend on the framework you use - that is, it’s not a Scala programming language question.

I’d recommend looking at an actual actor framework. Akka, for example, has excellent documentation: Actors • Akka Documentation

The examples in their docs will explain everything you need to know to get started with actors, distributed systems, coordinated shutdown etc.

I would consider it bad design to use System.exit inside your actors to signal something. You are very short on explaining why you want something, so there’s no good advice to give. But I would look into defining restart policies and supervision strategies within your actor system in order to properly shut it down if a fatal condition occurs. (I assume you are using Akka?)

1 Like