~statik/ubuntu/karmic/couchdb/fix-bug427036

« back to all changes in this revision

Viewing changes to src/couchdb/couch_db_update_notifier_sup.erl

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine, Elliot Murphy
  • Date: 2009-08-24 15:44:14 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090824154414-c9fytg3azvyuc8z3
Tags: 0.10.0~svn806985-0ubuntu1
* First snapshot of couchdb 0.10pre, from
  http://build.couchdb.org/0.10.x-UNOFFICIAL (LP: #418288)
* debian/postinst
  - Make /etc/couchdb/local.ini world readable (LP: #403575)

[Elliot Murphy]
* Added debian/patches/oauth_ini_users.patch from
  http://issues.apache.org/jira/browse/COUCHDB-478

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
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
 
2
% use this file except in compliance with the License. You may obtain a copy of
3
3
% the License at
4
4
%
5
5
%   http://www.apache.org/licenses/LICENSE-2.0
6
6
%
7
7
% Unless required by applicable law or agreed to in writing, software
8
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
 
9
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
10
% License for the specific language governing permissions and limitations under
11
11
% the License.
12
12
 
29
29
        couch_db_update_notifier_sup, []).
30
30
 
31
31
init([]) ->
32
 
    Self = self(),
33
32
    ok = couch_config:register(
34
 
        fun("update_notification", _) ->
35
 
            exit(Self, reload_config)
36
 
        end),
37
 
    
 
33
        fun("update_notification", Key, Value) -> reload_config(Key, Value) end
 
34
    ),
 
35
 
38
36
    UpdateNotifierExes = couch_config:get("update_notification"),
39
37
 
40
38
    {ok,
41
 
        {{one_for_one, 10, 3600}, 
 
39
        {{one_for_one, 10, 3600},
42
40
            lists:map(fun({Name, UpdateNotifierExe}) ->
43
41
                {Name,
44
42
                {couch_db_update_notifier, start_link, [UpdateNotifierExe]},
46
44
                    1000,
47
45
                    supervisor,
48
46
                    [couch_db_update_notifier]}
49
 
                end, UpdateNotifierExes)}}.
 
 
b'\\ No newline at end of file'
 
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