I work on project using Spring boot 2.1 and embedded jetty server 9 and I faced with problem of implementing graceful shutdown mechanism. After discussing with team it was decided to implement next graceful shutdown politics:
- all already incoming requests must be completed
- all incoming requests after
SIGTERMsignal should be rejected with503 status code - health endpoint should work after
SIGTERMMoreover application uses mongodb as database and if request communicate with mongo it should be completed as usual.
If I set flag setStopAtShutdown(true) and setStopTimeout() of jetty server all endpoints included /health starts to be unavailable but without these options they gets new requests after SIGTERM.
Also application context invokes close() method and beans starts to destroy. In this way requests depends on mongo fails with exceptions.
Can we help me with that problem?