Hi there, is there a way to make ktor on kotlin-na...
# ktor
u
Hi there, is there a way to make ktor on kotlin-native stop on sigterm? I already
addShutdownHook
as suggested for java:
Copy code
applicationEngine.addShutdownHook {
        println("Shutdown hook received")
        println("Stopping engine")
        applicationEngine.stop(200, 500)
        println("Engine stopped")
    }
    applicationEngine.start(wait = true)
a
Unfortunately, there is a bug in the
addShutdownHook
method on native targets.
s
I am doing it like this, https://github.com/arrow-kt/suspendapp You can install
Signal
handlers on Kotlin Native, and back-pressure them on shutdown.
This should be sufficient to setup your own
addShutdownHook
extension for Ktor. https://github.com/arrow-kt/suspendapp/blob/main/src/nativeMain/kotlin/arrow/continuations/unsafe/unsafe.kt
u
thanks!
101 Views