Shutting down Ranch in a controlled way when an application stops
Whilst working on a project using Ranch as the underlying transport layer, we noticed that shutting down the application in production could take a significant amount of time.
At application exit the rannch listeners were being killed and then restarted. This is by design as the listeners were just being killed. Supervision at its best.
After a bit of digging, I found that an Application module supports both
According to the Ranch documentation, to perform an orderly shutdown you need to call
The end result was to use the prep_stop calling the stop_listener for each of the listeners in the application.