Scott Rankin
05/18/2023, 7:09 PMApplicationStopPreparing
and ApplicationStopping
[2], [3]. While testing I'm noticing my println("ApplicationStopPreparing")
is printing a couple times. Do I need to unsubscribe from the event if I am going to do things during ApplicationStopPreparing
that I only want to happen once? Is there guidance or documentation on the differences between these Application shutdown states and the application lifecycle?
[1] https://ktor.io/docs/events.html
[2] https://api.ktor.io/ktor-server/ktor-server-core/io.ktor.server.application/-application-stop-preparing.html
[3] https://api.ktor.io/ktor-server/ktor-server-core/io.ktor.server.application/-application-stopping.htmlAleksei Tirman [JB]
05/19/2023, 6:29 AMScott Rankin
05/19/2023, 3:52 PMAleksei Tirman [JB]
05/22/2023, 6:06 AMApplicationStopPreparing
event is fired whenever the stop
method is called and the problem is that it's called twice - when the signal to terminate a program is sent and after unblocking the thread before shutting down the server. You can use a flag to run your code only once in an event handler.Scott Rankin
05/22/2023, 4:41 PM