aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch_server.erl
diff options
context:
space:
mode:
authorJames Fish <[email protected]>2013-04-01 23:47:02 +0100
committerJames Fish <[email protected]>2013-04-02 16:08:08 +0100
commitbb9f91b8658ab304a7038bcbca80dd518f53e026 (patch)
treeab43766e99b4bc4b156cd1a0f3978fd48ddf5854 /src/ranch_server.erl
parent109c63d0e76ca6248863932c7a9957f8093cfaf2 (diff)
downloadranch-bb9f91b8658ab304a7038bcbca80dd518f53e026.tar.gz
ranch-bb9f91b8658ab304a7038bcbca80dd518f53e026.tar.bz2
ranch-bb9f91b8658ab304a7038bcbca80dd518f53e026.zip
Add ranch_server state recovery
When ranch_server crashes it will now remonitor previously registered ranch_conns_sup processes so they can be removed from the registry when they die.
Diffstat (limited to 'src/ranch_server.erl')
-rw-r--r--src/ranch_server.erl4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ranch_server.erl b/src/ranch_server.erl
index d827ae2..7557d53 100644
--- a/src/ranch_server.erl
+++ b/src/ranch_server.erl
@@ -114,7 +114,9 @@ count_connections(Ref) ->
%% @private
init([]) ->
- {ok, #state{}}.
+ Monitors = [{{erlang:monitor(process, Pid), Pid}, Ref} ||
+ [Ref, Pid] <- ets:match(?TAB, {{conns_sup, '$1'}, '$2'})],
+ {ok, #state{monitors=Monitors}}.
%% @private
handle_call({set_new_listener_opts, Ref, MaxConns, Opts}, _, State) ->