couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r776715 - /couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl
Date Wed, 20 May 2009 14:41:00 GMT
Author: kocolosk
Date: Wed May 20 14:41:00 2009
New Revision: 776715

URL: http://svn.apache.org/viewvc?rev=776715&view=rev
Log:
restart update_notification process when config changes

Modified:
    couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl

Modified: couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl?rev=776715&r1=776714&r2=776715&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl Wed May 20 14:41:00 2009
@@ -31,12 +31,11 @@
 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 @@
                     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).
+



Mime
View raw message