diff options
author | Hans Nilsson <[email protected]> | 2017-04-07 15:16:56 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-04-07 15:16:56 +0200 |
commit | 3a29920a05cedee8c1f7501ee7b1aa22e068efed (patch) | |
tree | b9d7c89af83a12dbccc010e67c1f2472a1a8f8bf /lib/ssh/src/ssh_sup.erl | |
parent | 90aacace4bdb1c883c3829bc66c1c616a81943d9 (diff) | |
parent | b89f06569ee24011a8535c57d6a82e336afeb5bf (diff) | |
download | otp-3a29920a05cedee8c1f7501ee7b1aa22e068efed.tar.gz otp-3a29920a05cedee8c1f7501ee7b1aa22e068efed.tar.bz2 otp-3a29920a05cedee8c1f7501ee7b1aa22e068efed.zip |
Merge branch 'hans/ssh/supervisors/OTP-14267'
Diffstat (limited to 'lib/ssh/src/ssh_sup.erl')
-rw-r--r-- | lib/ssh/src/ssh_sup.erl | 75 |
1 files changed, 16 insertions, 59 deletions
diff --git a/lib/ssh/src/ssh_sup.erl b/lib/ssh/src/ssh_sup.erl index 8b57387589..26574763e4 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([]) -> - SupFlags = {one_for_one, 10, 3600}, - Children = 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]}, - Restart = permanent, - Shutdown = infinity, - Modules = [sshd_sup], - 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. - - - +init(_) -> + SupFlags = #{strategy => one_for_one, + intensity => 10, + period => 3600 + }, + ChildSpecs = [#{id => Module, + start => {Module, start_link, []}, + restart => permanent, + shutdown => 4000, %brutal_kill, + type => supervisor, + modules => [Module] + } + || Module <- [sshd_sup, + sshc_sup] + ], + {ok, {SupFlags,ChildSpecs}}. |