aboutsummaryrefslogtreecommitdiffstats
path: root/lib/megaco/src/engine/megaco_sup.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/megaco/src/engine/megaco_sup.erl
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/megaco/src/engine/megaco_sup.erl')
-rw-r--r--lib/megaco/src/engine/megaco_sup.erl116
1 files changed, 116 insertions, 0 deletions
diff --git a/lib/megaco/src/engine/megaco_sup.erl b/lib/megaco/src/engine/megaco_sup.erl
new file mode 100644
index 0000000000..c61a1da298
--- /dev/null
+++ b/lib/megaco/src/engine/megaco_sup.erl
@@ -0,0 +1,116 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%
+%%----------------------------------------------------------------------
+%% Purpose: The top supervisor for the Megaco/H.248 application
+%%----------------------------------------------------------------------
+
+-module(megaco_sup).
+
+-behaviour(application).
+-behaviour(supervisor).
+
+%% public
+-export([start/0, start/2, stop/1]).
+-export([start_sup_child/1, stop_sup_child/1]).
+
+%% internal
+-export([init/1]).
+
+%% debug
+-export([supervisor_timeout/1]).
+
+
+%% -define(d(F,A), io:format("~p~p:" ++ F ++ "~n", [self(),?MODULE|A])).
+-define(d(F,A), ok).
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% application and supervisor callback functions
+
+start(normal, Args) ->
+ ?d("start(normal) -> entry with"
+ "~n Args: ~p", [Args]),
+ SupName = {local, ?MODULE},
+ case supervisor:start_link(SupName, ?MODULE, [Args]) of
+ {ok, Pid} ->
+ {ok, Pid, {normal, Args}};
+ Error ->
+ Error
+ end;
+start(_, _) ->
+ {error, badarg}.
+
+start() ->
+ ?d("start -> entry", []),
+ SupName = {local,?MODULE},
+ supervisor:start_link(SupName, ?MODULE, []).
+
+stop(_StartArgs) ->
+ ok.
+
+init([]) -> % Supervisor
+ init();
+init([[]]) -> % Application
+ init();
+init(BadArg) ->
+ ?d("init -> entry when"
+ "~n BadArg: ~p",[BadArg]),
+ {error, {badarg, BadArg}}.
+
+init() ->
+ ?d("init -> entry", []),
+ Flags = {one_for_one, 0, 1},
+ Sups = [sup_spec(megaco_misc_sup),
+ sup_spec(megaco_trans_sup),
+ worker_spec(megaco_config, [gen_server]),
+ worker_spec(megaco_monitor, [gen_server])],
+ ?d("init -> done when"
+ "~n Flags: ~p"
+ "~n Sups: ~p", [Flags, Sups]),
+ {ok, {Flags, Sups}}.
+
+
+start_sup_child(Name) ->
+ ?d("start_sup_child -> entry with Name: ~p", [Name]),
+ Spec = sup_spec(Name),
+ supervisor:start_child(?MODULE, Spec).
+
+
+stop_sup_child(Name) ->
+ ?d("stop_sup_child -> entry with Name: ~p", [Name]),
+ ok = supervisor:terminate_child(?MODULE, Name),
+ ok = supervisor:delete_child(?MODULE, Name).
+
+
+
+sup_spec(Name) ->
+ {Name, {Name, start, []}, permanent, 2000, supervisor,[Name, supervisor]}.
+
+worker_spec(Name, Modules) ->
+ {Name, {Name, start_link, []}, permanent, 2000, worker, [Name] ++ Modules}.
+
+-ifdef(debug_shutdown).
+supervisor_timeout(_KillAfter) -> timer:hours(500).
+-else.
+supervisor_timeout(KillAfter) -> KillAfter.
+-endif.
+
+