例子

例子

启动来自 gen_server一章 的服务器的督程的回调模块可以是:

-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]}]}}.

one_for_one 是 重启策略 。

1和60定义了 最大重启频率 。

元组 {ch3, …} 是 子进程规格 。