wait_for_connections(Ref :: ranch:ref(), Operator, NumConns :: non_neg_integer()) -> ok Operator :: '>' | '>=' | '==' | '=<' | '<'
ranch:wait_for_connections - Wait for a specific number of connections
wait_for_connections(Ref :: ranch:ref(), Operator, NumConns :: non_neg_integer()) -> ok Operator :: '>' | '>=' | '==' | '=<' | '<'
Wait for a specific number of connections.
This function waits until the number of connections on the given listener becomes higher than, equal to or lower than the given number. It never returns otherwise.
This function can be used to gracefully shutdown a listener by first suspending the listener and then waiting for connections to terminate before finally stopping the listener.
The listener name.
The operator to use for the comparison.
The number of connections to reach.
The atom ok
is always returned. It can be safely ignored.
ranch:wait_for_connections(example, '>=', 100).
Ref = example, ok = ranch:suspend_listener(Ref), ranch:wait_for_connections(Ref, '==', 0), ok = ranch:stop_listener(Ref).
ranch:stop_listener(3), ranch:suspend_listener(3), ranch:resume_listener(3), ranch(3)
Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:
Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.