Current section
Files
Jump to
Current section
Files
lib/ant/supervisor.ex
defmodule Ant.Supervisor do
use Supervisor
# A simple module attribute that stores the supervisor name
@name Ant.Supervisor
def start_link do
Supervisor.start_link(__MODULE__, :ok, name: @name)
end
def spawn_ant do
Supervisor.start_child(@name, [])
end
def init(:ok) do
children = [
worker(Ant, [], restart: :temporary)
]
supervise(children, strategy: :simple_one_for_one)
end
end