Why is Ktor so slow to restart? Start itself is a...
# ktor
u
Why is Ktor so slow to restart? Start itself is almost instant. But stopping seems to take like 4 seconds. Which is painful when developing - it's so much noticably slower than when working on spring. Or is this a intellij thing?
1
j
Do you have a termination grace period set?
u
not that I'm aware of, just a hello world basically (with websocket)
j
You probably want to change the value for
shutdownTimeout
when running your server locally. The default is 5 seconds, which adds an intentional 5 second delay before shutting down, to let any async processes cool off
🙌 2
u
hm any idea where should I pass it to if all I have is basically
Copy code
fun main(args: Array<String>) {
    embeddedServer(
        factory = Netty,
        host = "0.0.0.0",
        port = 8081,
    ) {
        module()
    }.start(wait = true)
}
j
you're on Ktor 2.0+ 3.0+ right?
u
ktor-version = "3.1.1"
j
Oh I meant 3.0+
Copy code
fun main(args: Array<String>) {
    embeddedServer(
        factory = Netty,
        host = "0.0.0.0",
        port = 8081,
        configure = {
          shutdownGracePeriod = xxx
          shutdownTimeout = yyy
        }
    ) {
        module()
    }.start(wait = true)
}
I think that should do it
This is where we do it at my company
u
okay I see the
configure
overload; but then there's no host/port; guess I'll lokt into it thanks!
j
Copy code
fun main(args: Array<String>) {
    embeddedServer(
        factory = Netty,
        configure = {
          connector {
            host = "0.0.0.0"
            port = 8081
          }
          shutdownGracePeriod = xxx
          shutdownTimeout = yyy
        }
    ) {
        module()
    }.start(wait = true)
}
how about something like this?
u
works, great!
j
yay, great to hear 🙂