summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_db_update_notifier_sup.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-05-20 14:41:08 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-05-20 14:41:08 +0000
commit0292cbac7611bfa101bae29f31f9723001677752 (patch)
tree2c239a59b8524529e58f4d3556d13ec93ed16ad2 /src/couchdb/couch_db_update_notifier_sup.erl
parent839434c722b90b9e3681f77483538127dc0c09fd (diff)
restart update_notification process when config changes
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@776715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_db_update_notifier_sup.erl')
-rw-r--r--src/couchdb/couch_db_update_notifier_sup.erl25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/couchdb/couch_db_update_notifier_sup.erl b/src/couchdb/couch_db_update_notifier_sup.erl
index 0662fe77..69d6b1b0 100644
--- a/src/couchdb/couch_db_update_notifier_sup.erl
+++ b/src/couchdb/couch_db_update_notifier_sup.erl
@@ -31,12 +31,11 @@ start_link() ->
init([]) ->
Self = self(),
ok = couch_config:register(
- fun("update_notification", _) ->
- exit(Self, reload_config)
- end),
+ fun("update_notification", Key, Value) -> reload_config(Key, Value) end
+ ),
UpdateNotifierExes = couch_config:get("update_notification"),
-
+
{ok,
{{one_for_one, 10, 3600},
lists:map(fun({Name, UpdateNotifierExe}) ->
@@ -46,4 +45,20 @@ init([]) ->
1000,
supervisor,
[couch_db_update_notifier]}
- end, UpdateNotifierExes)}}. \ No newline at end of file
+ end, UpdateNotifierExes)}}.
+
+%% @doc when update_notification configuration changes, terminate the process
+%% for that notifier and start a new one with the updated config
+reload_config(Id, Exe) ->
+ ChildSpec = {
+ Id,
+ {couch_db_update_notifier, start_link, [Exe]},
+ permanent,
+ 1000,
+ supervisor,
+ [couch_db_update_notifier]
+ },
+ supervisor:terminate_child(couch_db_update_notifier_sup, Id),
+ supervisor:delete_child(couch_db_update_notifier_sup, Id),
+ supervisor:start_child(couch_db_update_notifier_sup, ChildSpec).
+