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
|
-module(plop_sup).
-behaviour(supervisor).
-export([start_link/1, init/1]).
-export([start_in_shell/1]).
start_link(Args) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, Args).
%% For testing.
start_in_shell(Args) ->
{ok, Pid} = start_link(Args),
unlink(Pid).
%% Supervisor callback
init(Args) ->
{ok, {{one_for_one, 3, 10},
[{the_db,
{db, start_link, []},
permanent,
10000,
worker, [db]},
{the_plop,
{plop, start_link, Args}, % All arguments go to plop.
permanent,
10000, % Shut down within 10s.
worker, [plop]}]}}.
|