Hi folks. We noticed that when a Ktor kubernetes p...
# ktor
c
Hi folks. We noticed that when a Ktor kubernetes pod is terminating, we’re failing requests received in the k8s Service. On closer inspection, it seems like Ktor is automatically closing the server and refusing new connections, when it receives a SIGTERM. It takes a while for the load balancer to detect that the host is down. Is there any way to do a graceful shutdown, accepting requests for a specified amount of time (instead of closing the ktor server)? Ideally, on sigterm we’d like to have something like this in ktor:
Copy code
SIGTERM received:
/health -> return 503 Service Unavailable
/v1/my-api -> return 200 OK

shutdown after X seconds
Do you think it’s possible to implement something like this? (we’re using ktor.server.EngineMain). PS: To its credit, on sigterm, ktor does wait for existing requests to finish.
👀 2