Hi there,
I have akka.coordinated-shutdown.run-by-jvm-shutdown-hook
set true (it’s default).
Akka Streams version 2.5.22.
For the following code:
CoordinatedShutdown(system).addTask(CoordinatedShutdown.PhaseBeforeServiceUnbind, "graceful-kill")(() => {
killSwitch.shutdown()
Future(done())
})
CoordinatedShutdown(system).addTask(CoordinatedShutdown.PhaseBeforeActorSystemTerminate, "wait-streams-finished")(() => {
streams.foreach(Await.ready(_, 1.minutes))
Future(done())
})
system.registerOnTermination(db.close())
sys.addShutdownHook {
logger.info("Terminating Actor system...")
Await.result(system.whenTerminated, Duration.Inf)
logger.info("Actor system terminated")
}
sometimes the app terminates with both graceful-kill
and wait-streams-finished
phases executed, and sometimes with only graceful-kill
, sometimes with neither. despite the hook system.registerOnTermination(db.close())
is always executed and awaited.
What am I doing wrong?
Thank you very much.