Harald Welte | fbd4f73 | 2012-05-06 23:29:42 +0200 | [diff] [blame] | 1 | % 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 Welte | 09a80c0 | 2012-05-08 23:37:33 +0200 | [diff] [blame^] | 40 | -export([get_as_fsm_name/1]). |
| 41 | |
Harald Welte | fbd4f73 | 2012-05-06 23:29:42 +0200 | [diff] [blame] | 42 | init([Name, Options]) -> |
Harald Welte | 09a80c0 | 2012-05-08 23:37:33 +0200 | [diff] [blame^] | 43 | AsName = get_as_fsm_name(Name), |
Harald Welte | ee7964c | 2012-05-07 23:55:02 +0200 | [diff] [blame] | 44 | StartArgs = [{local, AsName}, xua_as_fsm, [self()], Options], |
Harald Welte | fbd4f73 | 2012-05-06 23:29:42 +0200 | [diff] [blame] | 45 | 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 | |
| 53 | start_link(Name, Options) -> |
| 54 | supervisor:start_link(?MODULE, [Name, Options]). |
Harald Welte | 09a80c0 | 2012-05-08 23:37:33 +0200 | [diff] [blame^] | 55 | |
| 56 | get_as_fsm_name(Name) -> |
| 57 | list_to_atom("sg_as_" ++ Name ++ "_fsm"). |