Open webleaf opened 8 months ago
If you look at implementation of Server.start()
method - it registers a JVM shutdown hook to do a graceful shutdown, which is actually implemented by jdk.httpserver
itself - it closes the port, so that proxies/load balancers know that it doesn't accept any more requests, but finishes the currently running ones for up to 3 seconds (you can specify your value as a parameter). There are no 503 responses, as these may be propagated to the end-user.
Docker/Heroku/Google Cloud Run/Fly.io - all do this correctly. In general, they will start a new container, wait for it to open http port and then redirect traffic there. This should work the same no matter which framework do you use.
Docker and all of the the above would do it automatically for you.
Klite doesn't have any magic built it, but it restarts in less than 1 second, so you just change your code/run tests and then restart the server when ready. JVM hot reload works for changed code inside of functions, but not signatures, like usual. Usually classloader auto-reload hacks are needed if your server starts slowly.
In general, Klite is built with 12-factor apps principles in mind regarding deployment.
I have a few questions: