supervisor_separate.erl 467 B

12345678910111213141516
  1. -module(supervisor_separate).
  2. -behavior(supervisor).
  3. -behavior(ranch_protocol).
  4. -export([start_link/4]).
  5. -export([init/1]).
  6. start_link(Ref, Socket, Transport, Opts) ->
  7. {ok, SupPid} = supervisor:start_link(?MODULE, []),
  8. {ok, ConnPid} = supervisor:start_child(SupPid,
  9. {echo_protocol, {echo_protocol, start_link, [Ref, Socket, Transport, Opts]},
  10. temporary, 5000, worker, [echo_protocol]}),
  11. {ok, SupPid, ConnPid}.
  12. init([]) ->
  13. {ok, {{one_for_one, 1, 1}, []}}.