From 0292cbac7611bfa101bae29f31f9723001677752 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Wed, 20 May 2009 14:41:08 +0000 Subject: restart update_notification process when config changes git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@776715 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_db_update_notifier_sup.erl | 25 ++++++++++++++++++++----- 1 file 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). + -- cgit v1.2.3