'How to accept http requests after shutdown signal in Quarkus?

I tried this:

void onShutdown(@Observes final ShutdownEvent event) throws InterruptedException {
    log.infof("ShutdownEvent received, waiting for %s seconds before shutting down", shutdownWaitSeconds);
    TimeUnit.SECONDS.sleep(shutdownWaitSeconds);
    log.info("Continue shutting down");
}

But after receiving ShutdownEvent Quarkus already responds with 503 to http requests. Looks like this could be done with ShutdownListener in preShutdown method. I have implemented this listener but it does not get called yet. How do I register ShutdownListener?

Use case here is OpenShift sending requests to terminating pod.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source