summaryrefslogtreecommitdiff
path: root/lib/ssh/src/sshc_sup.erl
diff options
context:
space:
mode:
authorHans Nilsson <hans@erlang.org>2017-03-23 16:53:53 +0100
committerHans Nilsson <hans@erlang.org>2017-04-07 10:23:35 +0200
commit8f4bb9b0bd3aed663521371726ea3ec460e231a0 (patch)
tree78957c1854efbe5c556a1f2ef99dcbc72a3ac81a /lib/ssh/src/sshc_sup.erl
parent6158cb432092c47e178b4dc1177b46cb8c310ab4 (diff)
downloaderlang-8f4bb9b0bd3aed663521371726ea3ec460e231a0.tar.gz
ssh: Mappify supervisors
Diffstat (limited to 'lib/ssh/src/sshc_sup.erl')
-rw-r--r--lib/ssh/src/sshc_sup.erl35
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/ssh/src/sshc_sup.erl b/lib/ssh/src/sshc_sup.erl
index 9aab9d57e9..c71b81dc6d 100644
--- a/lib/ssh/src/sshc_sup.erl
+++ b/lib/ssh/src/sshc_sup.erl
@@ -32,18 +32,20 @@
%% Supervisor callback
-export([init/1]).
+-define(SSHC_SUP, ?MODULE).
+
%%%=========================================================================
%%% API
%%%=========================================================================
start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+ supervisor:start_link({local,?SSHC_SUP}, ?MODULE, []).
start_child(Args) ->
supervisor:start_child(?MODULE, Args).
stop_child(Client) ->
spawn(fun() ->
- ClientSup = whereis(?MODULE),
+ ClientSup = whereis(?SSHC_SUP),
supervisor:terminate_child(ClientSup, Client)
end),
ok.
@@ -52,19 +54,16 @@ stop_child(Client) ->
%%% Supervisor callback
%%%=========================================================================
init(_) ->
- RestartStrategy = simple_one_for_one,
- MaxR = 0,
- MaxT = 3600,
- {ok, {{RestartStrategy, MaxR, MaxT}, [child_spec()]}}.
-
-%%%=========================================================================
-%%% Internal functions
-%%%=========================================================================
-child_spec() ->
- Name = undefined, % As simple_one_for_one is used.
- StartFunc = {ssh_connection_handler, start_link, []},
- Restart = temporary,
- Shutdown = 4000,
- Modules = [ssh_connection_handler],
- Type = worker,
- {Name, StartFunc, Restart, Shutdown, Type, Modules}.
+ SupFlags = #{strategy => simple_one_for_one,
+ intensity => 0,
+ period => 3600
+ },
+ ChildSpecs = [#{id => undefined, % As simple_one_for_one is used.
+ start => {ssh_connection_handler, start_link, []},
+ restart => temporary,
+ shutdown => 4000,
+ type => worker,
+ modules => [ssh_connection_handler]
+ }
+ ],
+ {ok, {SupFlags,ChildSpecs}}.