-
Notifications
You must be signed in to change notification settings - Fork 0
/
echo_supervisor.erl
44 lines (33 loc) · 1.21 KB
/
echo_supervisor.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(echo_supervisor).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
init([]) ->
Dog =
{dog,
{echo_server, start_link, [dog, "Woof!", 3000]},
permanent, 2000, worker, dynamic},
HungryCat =
{hungry_cat,
{echo_server, start_link, [hungry_cat, "*meow*", 4000]},
permanent, 2000, worker, dynamic},
HappyCat =
{happy_cat,
{echo_server, start_link, [happy_cat, "*purrrrrr*", 1500]},
permanent, 2000, worker, dynamic},
Children = [Dog, HungryCat, HappyCat],
{ok, {{one_for_one, 3, 10}, Children}}.
%%====================================================================
%% Internal functions
%%====================================================================