blob: 6a2f2f298a3a267820e4476724b4707b3c570704 [file] [log] [blame]
Harald Weltefbd4f732012-05-06 23:29:42 +02001% SIGTRAN SGW AS supervisor
2
3% (C) 2012 by Harald Welte <laforge@gnumonks.org>
4%
5% All Rights Reserved
6%
7% This program is free software; you can redistribute it and/or modify
8% it under the terms of the GNU Affero General Public License as
9% published by the Free Software Foundation; either version 3 of the
10% License, or (at your option) any later version.
11%
12% This program is distributed in the hope that it will be useful,
13% but WITHOUT ANY WARRANTY; without even the implied warranty of
14% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15% GNU General Public License for more details.
16%
17% You should have received a copy of the GNU Affero General Public License
18% along with this program. If not, see <http://www.gnu.org/licenses/>.
19%
20% Additional Permission under GNU AGPL version 3 section 7:
21%
22% If you modify this Program, or any covered work, by linking or
23% combining it with runtime libraries of Erlang/OTP as released by
24% Ericsson on http://www.erlang.org (or a modified version of these
25% libraries), containing parts covered by the terms of the Erlang Public
26% License (http://www.erlang.org/EPLICENSE), the licensors of this
27% Program grant you additional permission to convey the resulting work
28% without the need to license the runtime libraries of Erlang/OTP under
29% the GNU Affero General Public License. Corresponding Source for a
30% non-source form of such a combination shall include the source code
31% for the parts of the runtime libraries of Erlang/OTP used as well as
32% that of the covered work.
33
34-module(sg_as_sup).
35-author('Harald Welte <laforge@gnumonks.org>').
36-behaviour(supervisor).
37
38-export([init/1, start_link/2]).
39
Harald Welte09a80c02012-05-08 23:37:33 +020040-export([get_as_fsm_name/1]).
41
Harald Weltefbd4f732012-05-06 23:29:42 +020042init([Name, Options]) ->
Harald Welte09a80c02012-05-08 23:37:33 +020043 AsName = get_as_fsm_name(Name),
Harald Welteee7964c2012-05-07 23:55:02 +020044 StartArgs = [{local, AsName}, xua_as_fsm, [self()], Options],
Harald Weltefbd4f732012-05-06 23:29:42 +020045 StartFunc = {gen_fsm, start_link, StartArgs},
46 ChildSpec = {as_fsm, StartFunc, permanent, 4000, worker, [xua_as_fsm]},
47
48 AspsName = list_to_atom("sg_asp_" ++ Name ++ "_sup"),
49 StartFuncASPS = {supervisor, start_link, [{local, AspsName}, sg_asp_sup, [Name, self()]]},
50 ChildSpecASPS = {asp_sup, StartFuncASPS, permanent, 4000, worker, [asp_sup]},
51 {ok, {{one_for_all, 1, 1}, [ChildSpec, ChildSpecASPS]}}.
52
53start_link(Name, Options) ->
54 supervisor:start_link(?MODULE, [Name, Options]).
Harald Welte09a80c02012-05-08 23:37:33 +020055
56get_as_fsm_name(Name) ->
57 list_to_atom("sg_as_" ++ Name ++ "_fsm").