summaryrefslogtreecommitdiff
path: root/merge/src/merge_fetch_newentries_sup.erl
blob: bd33e6014c2efb61e92abb4c2005f232e8d96f76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
%%% Copyright (c) 2017, NORDUnet A/S.
%%% See LICENSE for licensing information.

-module(merge_fetch_newentries_sup).
-behaviour(supervisor).

-export([start_link/1, init/1]).

start_link(Nodes) ->
    {ok, Pid} = 
        supervisor:start_link({local, ?MODULE}, ?MODULE, []),
    Children = 
        lists:map(fun({NodeName, NodeAddress}) -> 
                          lager:info("starting newentry worker: ~p", [NodeName]),

                          {ok, Child} = supervisor:start_child(
                                          ?MODULE, 
                                          [{NodeName, NodeAddress, 3000}]),
                          Child
                  end, Nodes),
    lager:debug("~p started newentry workers: ~p", [Pid, Children]),
    {ok, Pid}.

init([]) ->
    {ok,
     {{simple_one_for_one, 3, 10},
      [{ignored,
        {merge_fetch_newentries, start_link, []},
        permanent, 10000, worker,
        [merge_fetch_newentries]}]}}.