We need the app to respond to SIGTERM but updating some state, maybe on app.state, that the /healthz endpoitnt can reference. This should cause /healthz to return 500 status code because that is what k8s (and other standard tools) actually check. The body (JSON...) is for humans.
The app needs to wait long enough for HAproxy (or k8s or whatever) to poll /healthz. I think we'll need this to be configurable somehow because for dev and small deployments we do not want to wait ~10 for the app to shutdown after receiving SIGTERM.
In the shutdoown ASGI lifecycle hook...
https://github.com/bluesky/tiled/blob/7f7329de1b4ab39f502075656102585cdcc35f7c/tiled/server/app.py#L668
...
We need the app to respond to
SIGTERM
but updating some state, maybe onapp.state
, that the/healthz
endpoitnt can reference. This should cause/healthz
to return500
status code because that is what k8s (and other standard tools) actually check. The body (JSON...) is for humans.The app needs to wait long enough for HAproxy (or k8s or whatever) to poll
/healthz
. I think we'll need this to be configurable somehow because for dev and small deployments we do not want to wait ~10 for the app to shutdown after receivingSIGTERM
.