By default, Akka shuts down the actor system(s) when it receives a SIGTERM
. How can I override this behaviour to do my custom shutdown logic before shutting down the akka system? I already have this logic implemented in the actors, using special graceful stop messages - I just need to invoke that logic when the SIGTERM
is received.
Or do I have to use some other way of shutting down the application? That is also an option.
You can just use sys.shutdownHookThread
like this:
def main(args: Array[String]) {
... initialization code ...
sys.shutdownHookThread {
println "Shutting down ..."
shutdownHandler ! DoSomething
}
}
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