Generated on 2009-08-09 21:22:57 with etap 0.3.4.
| Name | Total lines | Lines of code | Total coverage | Code coverage | ||||
| couch_db_update_notifier_sup | ?? | ?? | ?? |
|
....1 % Licensed under the Apache License, Version 2.0 (the "License"); you may not ....2 % use this file except in compliance with the License. You may obtain a copy of ....3 % the License at ....4 % ....5 % http://www.apache.org/licenses/LICENSE-2.0 ....6 % ....7 % Unless required by applicable law or agreed to in writing, software ....8 % distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ....9 % WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the ...10 % License for the specific language governing permissions and limitations under ...11 % the License. ...12 ...13 % ...14 % This causes an OS process to spawned and it is notified every time a database ...15 % is updated. ...16 % ...17 % The notifications are in the form of a the database name sent as a line of ...18 % text to the OS processes stdout. ...19 % ...20 ...21 -module(couch_db_update_notifier_sup). ...22 ...23 -behaviour(supervisor). ...24 ...25 -export([start_link/0,init/1]). ...26 ...27 start_link() -> ...28 supervisor:start_link({local, couch_db_update_notifier_sup}, ...29 couch_db_update_notifier_sup, []). ...30 ...31 init([]) -> ...32 ok = couch_config:register( ...33 fun("update_notification", Key, Value) -> reload_config(Key, Value) end ...34 ), ...35 ...36 UpdateNotifierExes = couch_config:get("update_notification"), ...37 ...38 {ok, ...39 {{one_for_one, 10, 3600}, ...40 lists:map(fun({Name, UpdateNotifierExe}) -> ...41 {Name, ...42 {couch_db_update_notifier, start_link, [UpdateNotifierExe]}, ...43 permanent, ...44 1000, ...45 supervisor, ...46 [couch_db_update_notifier]} ...47 end, UpdateNotifierExes)}}. ...48 ...49 %% @doc when update_notification configuration changes, terminate the process ...50 %% for that notifier and start a new one with the updated config ...51 reload_config(Id, Exe) -> ...52 ChildSpec = { ...53 Id, ...54 {couch_db_update_notifier, start_link, [Exe]}, ...55 permanent, ...56 1000, ...57 supervisor, ...58 [couch_db_update_notifier] ...59 }, ...60 supervisor:terminate_child(couch_db_update_notifier_sup, Id), ...61 supervisor:delete_child(couch_db_update_notifier_sup, Id), ...62 supervisor:start_child(couch_db_update_notifier_sup, ChildSpec). ...63
Generated using etap 0.3.4.