# RanchConnectionDrainer [![Hex pm](](

This mini library implements connection draining for servers that use Ranch (Cowboy, Plug, Phoenix, and maybe others).

## Installation

This package can be installed by adding `ranch_connection_drainer` to your list of dependencies in `mix.exs`:

def deps do
    {:ranch_connection_drainer, "~> 0.1.0"}

Then add `{RanchConnectionDrainer, ranch_ref: my_ranch_ref, shutdown: my_drain_timeout}` to your application supervisor directly under your phoenix endpoint.


children = [
  {RanchConnectionDrainer, ranch_ref: MyPhoenixProject.Endpoint.HTTP, shutdown: 30_000}
Supervisor.init(children, opts)

The format of `ranch_ref` is: `[PhoenixEndpoint].[HTTP | HTTPS]`. Please open an issue if this is unclear.