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).