summaryrefslogtreecommitdiff
path: root/src/code/2/echo_server/lib/echo_server/supervisor.ex
blob: e770a3a4b07791b2803ca05048dea6ef0a48efee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
defmodule EchoServer.Supervisor do
  use Supervisor

  def start_link do
    Supervisor.start_link(__MODULE__, [], name: __MODULE__)
  end

  def init(_) do
    children = [
      supervisor(Task.Supervisor, [[name: EchoServer.TaskSupervisor]]),
      worker(Task, [EchoServer.Echo, :accept, [1337]])
    ]

    opts = [strategy: :one_for_one]
    supervise(children, opts)
  end

end