summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@ca.ibm.com>2015-04-02 07:47:06 -0700
committerILYA Khlopotov <iilyak@ca.ibm.com>2015-04-02 07:54:37 -0700
commit461b9d112188ae35965269d6d0f9c5eceeea90c3 (patch)
treef7f9b9e2608860136067a7b32f2e0cb147f2e192
parent475ad18e22b31b4f180eb8f20e4a61c7cd738e80 (diff)
downloadcouchdb-461b9d112188ae35965269d6d0f9c5eceeea90c3.tar.gz
Use updated config_listener behaviour
BugzID: 45855
-rw-r--r--src/custodian/src/custodian_server.erl21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/custodian/src/custodian_server.erl b/src/custodian/src/custodian_server.erl
index e825c07f5..85095d12b 100644
--- a/src/custodian/src/custodian_server.erl
+++ b/src/custodian/src/custodian_server.erl
@@ -2,7 +2,7 @@
-module(custodian_server).
-behaviour(gen_server).
--vsn(1).
+-vsn(2).
-behaviour(config_listener).
% public api.
@@ -19,7 +19,7 @@
]).
% config_listener callback
--export([handle_config_change/5]).
+-export([handle_config_change/5, handle_config_terminate/3]).
% private records.
-record(state, {
@@ -35,12 +35,19 @@
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-handle_config_change("cloudant", "maintenance_mode", _, _, S) ->
+handle_config_change("couchdb", "maintenance_mode", _, _, S) ->
ok = gen_server:cast(S, refresh),
{ok, S};
handle_config_change(_, _, _, _, S) ->
{ok, S}.
+handle_config_terminate(_, _, _) -> ok;
+handle_config_terminate(Self, _, _) ->
+ spawn(fun() ->
+ timer:sleep(5000),
+ config:listen_for_changes(?MODULE, Self)
+ end).
+
% gen_server functions.
init(_) ->
process_flag(trap_exit, true),
@@ -57,14 +64,6 @@ handle_call(_Msg, _From, State) ->
handle_cast(refresh, State) ->
{noreply, start_shard_checker(State)}.
-handle_info({gen_event_EXIT, {config_listener, ?MODULE}, _Reason}, State) ->
- erlang:send_after(5000, self(), restart_config_listener),
- {noreply, State};
-
-handle_info(restart_config_listener, State) ->
- ok = config:listen_for_changes(?MODULE, self()),
- {noreply, State};
-
handle_info({nodeup, _}, State) ->
{noreply, start_shard_checker(State)};