I’ve been using ApplicationLifecycle and I’m trying to replace it with CoordinatedShutdown. What I’m doing right now is moving my stophooks to CoordinatedShutdown.PhaseServiceStop(), and I’m seeing this warning: Coordinated shutdown phase [service-stop] timed out after 5000 milliseconds
So is there a way around this? Can I configure the timeout somehow? Thanks!
Not per hook. All of the hooks within a phase are run concurrently, so you should set the timeout of the phase to the longest of the hooks you are running. If you need more flexibility than that, you can put hooks in different phases or create custom phases.
Note also that when a timeout triggers, it doesn’t halt the stop hook, it just moves on to the next phase. Eventually, the process will terminate after all phases complete or timeout.
Hard to say. I agree that you’d expect that if the behavior hasn’t changed. Are you actually expecting your hook to take longer than five seconds? Is it possible that the translation introduced a bug causing the returned Future not to complete? Can you post your code?
So I’ve actually been managing my own stop hooks and ordering, and I have a method private CompletionStage<Void> onStop(), and I was using lifecycle.addStopHook(this::onStop); to regster it with ApplicationLifecycle. And now with CoordinatedShutdown, this is what I’m doing:
I don’t see an obvious reason why the Play stop hook would complete in time but the new coordinated shutdown task wouldn’t. I guess the interesting things happen within onStop, so it would be good to see that.
Play has only stopped its ApplicationLifecycle within an Akka Coordinated Shutdown phase since version 2.7.0. Prior to that, it would wait indefinitely for the stop hooks to complete. Could that explain the discrepancy? Did you try the original hook with Play 2.7.0 or later?