Hi friends, I have a use case where I need to brin...
# ktor
s
Hi friends, I have a use case where I need to bring Ktor (Netty) server up with a single endpoint to expose metrics, run a long task and then bring the server down when it's done. How can I programmatically shutdown the server and exit after the task is complete?
b
Doesn't embeddedServer() work for you?
s
It does for serving up the metrics, but it stays up after the task is complete. I need to bring the server down.
oh, it looks like there's a
stop
function on the engine interface.
👍 1
I'll try that.
d
Without having looked at the implementation: there is a shutdown endpoint feature. You could either use that to explicitly shut down the server after usage or have a look at the code to see how the server is actually shut down there.
f