Using ranch, how can I tell when a listener is terminated?

425 Views Asked by At

I'm writing a TCP server in Erlang, using Ranch. The clients will reconnect immediately the connection is dropped, which means that one particular failure mode is listeners being started and killed dozens of times a second.

I'd like to detect this happening and publish statistics to statsd, for monitoring in production.

So, can I use something in Ranch to monitor when a listener is recycled? Or can I use something in Erlang to monitor process mortality for the entire node, without having to link to each process, and where those processes were started by some other supervisor, so I don't have a reference to them?

1

There are 1 best solutions below

0
Roger Lipscombe On

It's not a direct answer to my question, but I opted, instead, to have a separate process periodically polling ranch_server:count_connections(my_ref), and publish that to statsd.