/
gateway_config_sup.erl
66 lines (56 loc) · 2 KB
/
gateway_config_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%%%-------------------------------------------------------------------
%% @doc gateway-config top level supervisor.
%% @end
%%%-------------------------------------------------------------------
-module(gateway_config_sup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API functions
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
%% Child :: #{id => Id, start => {M, F, A}}
%% Optional keys are restart, shutdown, type, modules.
%% Before OTP 18 tuples must be used to specify a child. e.g.
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
{ok, B} = ebus:system(),
SupFlags = {one_for_all, 3, 10},
ChildSpecs = [
#{
id => gateway_config_worker,
start => {gateway_config_worker, start_link, [B]},
type => worker,
restart => permanent
},
#{
id => gateway_config_miner,
start => {gateway_config_miner, start_link, []},
type => worker,
restart => permanent
},
#{
id => gateway_config_led,
start => {gateway_config_led, start_link, [B]},
type => worker,
restart => permanent
},
#{
id => gateway_gatt_application,
restart => permanent,
type => supervisor,
start => {gatt_application_sup, start_link, [gateway_gatt_application, []]}
}
],
{ok, {SupFlags, ChildSpecs}}.
%%====================================================================
%% Internal functions
%%====================================================================