-module(ebb_worker_supv). -behaviour(supervisor). %% API -export([start_link/4]). %% Supervisor callbacks -export([init/1]). %%==================================================================== %% API functions %%==================================================================== %%-------------------------------------------------------------------- %% Function: start_link() -> {ok,Pid} | ignore | {error,Error} %% Description: Starts the supervisor %%-------------------------------------------------------------------- start_link(Mode, Func, Args, Receiver) -> supervisor:start_link(?MODULE, {Mode, Func, Args, Receiver}). %%==================================================================== %% Supervisor callbacks %%==================================================================== %%-------------------------------------------------------------------- %% Func: init(Args) -> {ok, {SupFlags, [ChildSpec]}} | %% ignore | %% {error, Reason} %% Description: Whenever a supervisor is started using %% supervisor:start_link/[2,3], this function is called by the new process %% to find out about restart strategy, maximum restart frequency and child %% specifications. %%-------------------------------------------------------------------- init({local, Func, Args, Receiver}) -> Worker = {'worker', {ebb_worker, start_link, [Func, Args, Receiver]}, transient, 2000, worker, [ebb_worker]}, {ok, {{one_for_one, 5, 1}, [Worker]}}; init({distributed, Func, Args, Receiver}) -> Worker = {'worker', {ebb_work_manager, start_work, [Func, Args, Receiver]}, temporary, 2000, worker, [ebb_work_manager]}, {ok, {{one_for_one, 5, 1}, [Worker]}}. %%==================================================================== %% Internal functions %%====================================================================