Does ulfius / microhttpd support a graceful shutdown of a service? I am thinking about the following scenario:
- A running service receives a TERM signal or similar trigger, e.g. a shutdown API that only privileged clients can call, to terminate
- The service catches this signal and executes a shutdown procedure with the following steps
- Make sure that no new requests are accepted - maybe by multiple measures
- Closing the listening socket to not accept new connections
- Return immediately HTTP code 503 (not sure if this is the best code to indicate that no new requests are accepted)
- Wait until all open requests are completed (including sending back the response to the clients)
- Shutdown the service completely
- Exit the process
The goal is to be as friendly as possible to clients and proxies:
- If an API is completed which also could mean some data is committed to database the service salso make sure to return a response to the client
- New requests should be rejected clearly so clients can implement some retry logic and proxies can redelegate to other instances
- Real shutdown should be done with no running API
I haven't found any ulfius examples that cover this. Is this something that could be supported in ulfius or implemented by the application?
Does ulfius / microhttpd support a graceful shutdown of a service? I am thinking about the following scenario:
The goal is to be as friendly as possible to clients and proxies:
I haven't found any ulfius examples that cover this. Is this something that could be supported in ulfius or implemented by the application?