init() -> {ok, {SupFlags, [ChildSpec,...]}} | ignore.
[ChildSpec,...] 是在init以后默认要启动的子进程。app
{Type, Times, Sec}函数
{Id, StartFunc, Restart, Shutdown, Type, Modules} %% 或者 #{ id => child_id(), start => mfaargs(), restart => restart(), shutdown => shutdown(), type => work(), modules => modules() }
permanent
: 若是app终止了,整个系统都会中止工做(application:stop/1除外)。transient
: 若是app以normal的缘由终止,没有影响。任何其它终止缘由都谁致使整个系统关闭。temporary
: app能够以任何缘由终止。只产生报告,没有其它任何影响。brutal_kill
: 无条件终止infinity
: 若是子进程是监控树,设置为无限大,等待其终止为止worker
: 普通子进程supervisor
: 子进程是监控树dynamic
: 当子进程是gen_event[Module]
: 当子进程是监控树、gen_server或者gen_fsm,表示回调模块名称Sup一般能够为?MODULE
rest
% 启动监控树 supervisor:start_link(Sup, []). % 启动一个子进程 supervisor:start_child(Sup, ChildSpec). % 中止一个子进程 supervisor:terminate(Sup, Id). % 删除一个子进程 supervisor:delete_child(Sup, Id).