1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2019-2019. 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-module(dtls_sup). 24 25-behaviour(supervisor). 26 27%% API 28-export([start_link/0]). 29 30%% Supervisor callback 31-export([init/1]). 32 33%%%========================================================================= 34%%% API 35%%%========================================================================= 36 37-spec start_link() -> {ok, pid()} | ignore | {error, term()}. 38 39start_link() -> 40 supervisor:start_link({local, ?MODULE}, ?MODULE, []). 41 42%%%========================================================================= 43%%% Supervisor callback 44%%%========================================================================= 45 46init([]) -> 47 DTLSConnectionManager = dtls_connection_manager_child_spec(), 48 DTLSServers = dtls_server_spec(), 49 50 {ok, {{one_for_one, 10, 3600}, [DTLSConnectionManager, 51 DTLSServers 52 ]}}. 53 54 55%%-------------------------------------------------------------------- 56%%% Internal functions 57%%-------------------------------------------------------------------- 58dtls_server_spec() -> 59 Name = dtls_servers, 60 StartFunc = {dtls_server_sup, start_link, []}, 61 Restart = permanent, 62 Shutdown = 4000, 63 Modules = [dtls_server_sup], 64 Type = supervisor, 65 {Name, StartFunc, Restart, Shutdown, Type, Modules}. 66 67dtls_connection_manager_child_spec() -> 68 Name = dtls_connection, 69 StartFunc = {dtls_connection_sup, start_link, []}, 70 Restart = permanent, 71 72 Shutdown = 4000, 73 Modules = [dtls_connection_sup], 74 Type = supervisor, 75 {Name, StartFunc, Restart, Shutdown, Type, Modules}. 76 77