Last active
August 25, 2017 11:32
Elixir 1.5 supervisor problem :simple_one_for_one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Sup do | |
use Supervisor | |
def start_link, do: Supervisor.start_link(__MODULE__, [], name: __MODULE__) | |
def init(_) do | |
agent_spec = Supervisor.child_spec(Child, start: {Child, :start_link, []}) | |
Supervisor.init([agent_spec], strategy: :simple_one_for_one) | |
end | |
def add_item(name), do: Supervisor.start_child(__MODULE__, [name]) | |
end | |
defmodule Child do | |
use GenServer | |
def start_link(_opts, name), do: GenServer.start_link(__MODULE__, [], name: name) | |
def init(_), do: {:ok, []} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{:error,
{:EXIT,
{:undef,
[{Child, :start_link, ["abc"], []},
{:supervisor, :do_start_child_i, 3, [file: 'supervisor.erl', line: 381]},
{:supervisor, :handle_call, 3, [file: 'supervisor.erl', line: 406]},
{:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 636]},
{:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 665]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}}