%%%----------------------------------------------------------------------------- %%% @copyright (C) 2013-2019, 2600Hz %%% @doc %%% @author James Aimonetti %%% @end %%%----------------------------------------------------------------------------- -module(crossbar_module_sup). -behaviour(supervisor). %% API -export([start_link/0 ,start_child/1, start_child/2 ]). %% Supervisor callbacks -export([init/1]). -include("crossbar.hrl"). -define(SERVER, ?MODULE). -define(CHILDREN, []). %%%============================================================================= %%% API functions %%%============================================================================= %%------------------------------------------------------------------------------ %% @doc Starts the supervisor. %% @end %%------------------------------------------------------------------------------ -spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). -spec start_child(module()) -> kz_types:sup_startchild_ret(). start_child(Mod) -> start_child(Mod, 'worker'). -spec start_child(module(), 'worker' | 'supervisor') -> kz_types:sup_startchild_ret(). start_child(Mod, 'worker') -> supervisor:start_child(?SERVER, ?WORKER(Mod)); start_child(Mod, 'supervisor') -> supervisor:start_child(?SERVER, ?SUPER(Mod)). %%%============================================================================= %%% Supervisor callbacks %%%============================================================================= %%------------------------------------------------------------------------------ %% @doc 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. %% @end %%------------------------------------------------------------------------------ -spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 1000, MaxSecondsBetweenRestarts = 3600, SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}, {'ok', {SupFlags, ?CHILDREN}}. %%%============================================================================= %%% Internal functions %%%=============================================================================