First, you create a supervisor process as part of an observation tree that calls supervisor:start_link/2or supervisor:start_link/3. The created dispatcher process calls Module:init/1to inquire about the restart strategy, maximum restart frequency and detailed specifications.
This is sample code for a supervisor starting gen_server (although you can run other gen_ * modules):
-module(ch_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link(ch_sup, []).
init(_Args) ->
{ok, {{one_for_one, 1, 60},
[{ch3, {ch3, start_link, []},
permanent, brutal_kill, worker, [ch3]}]}}.
{ch3, ...} , :
{Id, StartFunc, Restart, Shutdown, Type, Modules}
ch3 :
{ch3, {ch3, start_link, []}, permanent, brutal_kill, worker, [ch3]}
, ch3 , , one_for_one , . one_for_one , , , , , . , , .
start_child/2 SupRef, .
, supervisour , .