aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_sup.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-03-21 19:50:49 +0100
committerHans Nilsson <[email protected]>2017-04-07 10:23:34 +0200
commit6158cb432092c47e178b4dc1177b46cb8c310ab4 (patch)
tree8d6d5ff1f0f2b70eb7bc1cbe4e5fa5e440e3764e /lib/ssh/src/ssh_sup.erl
parent57d994270d63e7a9ce80eece3c1c3aeca79d3ea4 (diff)
downloadotp-6158cb432092c47e178b4dc1177b46cb8c310ab4.tar.gz
otp-6158cb432092c47e178b4dc1177b46cb8c310ab4.tar.bz2
otp-6158cb432092c47e178b4dc1177b46cb8c310ab4.zip
ssh: Fix supervisors, start daemon and connect code
Remove many internal options and made them as explicit arguments.
Diffstat (limited to 'lib/ssh/src/ssh_sup.erl')
-rw-r--r--lib/ssh/src/ssh_sup.erl53
1 files changed, 5 insertions, 48 deletions
diff --git a/lib/ssh/src/ssh_sup.erl b/lib/ssh/src/ssh_sup.erl
index 8b57387589..5463401dcd 100644
--- a/lib/ssh/src/ssh_sup.erl
+++ b/lib/ssh/src/ssh_sup.erl
@@ -31,63 +31,20 @@
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
--spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
-
-init([]) ->
+init(_) ->
SupFlags = {one_for_one, 10, 3600},
- Children = children(),
+ Children = [child_spec(sshd_sup), child_spec(sshc_sup)], %%children(),
{ok, {SupFlags, Children}}.
%%%=========================================================================
%%% Internal functions
%%%=========================================================================
-get_services() ->
- case (catch application:get_env(ssh, services)) of
- {ok, Services} ->
- Services;
- _ ->
- []
- end.
-
-children() ->
- Services = get_services(),
- Clients = [Service || Service <- Services, is_client(Service)],
- Servers = [Service || Service <- Services, is_server(Service)],
-
- [server_child_spec(Servers), client_child_spec(Clients)].
-
-server_child_spec(Servers) ->
- Name = sshd_sup,
- StartFunc = {sshd_sup, start_link, [Servers]},
+child_spec(Name) ->
+ StartFunc = {Name, start_link, []},
Restart = permanent,
Shutdown = infinity,
- Modules = [sshd_sup],
+ Modules = [Name],
Type = supervisor,
{Name, StartFunc, Restart, Shutdown, Type, Modules}.
-client_child_spec(Clients) ->
- Name = sshc_sup,
- StartFunc = {sshc_sup, start_link, [Clients]},
- Restart = permanent,
- Shutdown = infinity,
- Modules = [sshc_sup],
- Type = supervisor,
- {Name, StartFunc, Restart, Shutdown, Type, Modules}.
-
-is_server({sftpd, _}) ->
- true;
-is_server({shelld, _}) ->
- true;
-is_server(_) ->
- false.
-
-is_client({sftpc, _}) ->
- true;
-is_client({shellc, _}) ->
- true;
-is_client(_) ->
- false.
-
-
-