-
Notifications
You must be signed in to change notification settings - Fork 0
/
comd_sup.erl
47 lines (34 loc) · 1.23 KB
/
comd_sup.erl
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-module(comd_sup).
-behaviour(supervisor).
%% API
-export([start_link/2]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
-define(CMD, "./OldCoMD/CoMD -x 6 -y 6 -z 6").
%%-define(CMD, "./comd -x 123.0 -y 234.0 -z 345.0").
%%====================================================================
%% API
%%====================================================================
start_link(Pid, N) ->
supervisor:start_link(?MODULE, [Pid, N]).
%% supervisor:start_link({local, ?SERVER}, ?MODULE, [Pid, N]).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
init([Pid, N]) ->
L = lists:seq(0, N-1, 1),
Children = lists:map(
fun(I) ->
{mk_name("tag_", I),
{comd_srv, start_link, [mk_name("comd_", I), ?CMD, I, 0, Pid]},
transient, 2000, worker, dynamic}
end,
L
),
{ok, { {one_for_one, 50, 10}, Children }}.
%%====================================================================
%% Internal functions
%%====================================================================
mk_name(Base, N) ->
list_to_atom(Base ++ integer_to_list(N)).