Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

Coordinated Shutdown inconsistent behaviour for automatic JVM hook set to be true

$
0
0

@nkat wrote:

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.

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1362