1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2001-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20 21%% 22%%---------------------------------------------------------------------- 23%% Purpose: The top supervisor for the Megaco/H.248 application 24%%---------------------------------------------------------------------- 25 26-module(megaco_misc_sup). 27 28-behaviour(supervisor). 29 30%% public 31-export([start/0, start/2, stop/1, init/1]). 32-export([start_permanent_worker/4]). 33 34 35%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36%% application and supervisor callback functions 37 38start(normal, Args) -> 39 SupName = {local,?MODULE}, 40 case supervisor:start_link(SupName, ?MODULE, [Args]) of 41 {ok, Pid} -> 42 {ok, Pid, {normal, Args}}; 43 Error -> 44 Error 45 end; 46start(_, _) -> 47 {error, badarg}. 48 49start() -> 50 SupName = {local,?MODULE}, 51 supervisor:start_link(SupName, ?MODULE, []). 52 53stop(_StartArgs) -> 54 ok. 55 56init([]) -> % Supervisor 57 init(); 58init(BadArg) -> 59 {error, {badarg, BadArg}}. 60 61init() -> 62 Flags = {one_for_one, 0, 1}, 63 Workers = [], 64 {ok, {Flags, Workers}}. 65 66 67%%---------------------------------------------------------------------- 68%% Function: start_permanent_worker/3 69%% Description: Starts a permanent worker (child) process 70%%---------------------------------------------------------------------- 71 72start_permanent_worker(M, F, A, Modules) -> 73 Spec = {M, {M,F,A}, permanent, timer:seconds(1), worker, [M] ++ Modules}, 74 supervisor:start_child(?MODULE, Spec). 75 76 77 78 79