Ran Magen11/19/2019, 12:19 AM
. I can implement this myself, though if there's already a commonly used feature, I'd opt to not re-invent the wheel. My general idea is to set some boolean like
when getting a
and maintain another
with the current number of active requests similar to https://github.com/ktorio/ktor/blob/master/ktor-features/ktor-metrics/jvm/src/io/ktor/metrics/dropwizard/DropwizardMetrics.kt#L22 so when that number hits 0 and
var active: Int
is true, only then finish the process.
and have some graceful shutdown time. Right now they die while requests are in flight and we see a dip in success rate.
should suffice? we have them set to
Hm I'll go back to this. Maybe this is more of a k8s problem sending requests to the pod after the SIGTERM or maybe we have some very slow requests.
server.stop(gracePeriod = 10, timeout = 10, timeUnit = SECONDS)
napperley11/19/2019, 3:13 AM
Ran Magen11/19/2019, 7:11 PM
napperley11/19/2019, 11:30 PM
Ran Magen11/19/2019, 11:41 PM
fun onShutdown(action: () -> Unit) = Runtime.getRuntime().addShutdownHook(Thread(action))