Skip to content

Instantly share code, notes, and snippets.

@carlmartus
Last active August 25, 2017 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlmartus/86528478d13eff3a41936863c6a8a931 to your computer and use it in GitHub Desktop.
Save carlmartus/86528478d13eff3a41936863c6a8a931 to your computer and use it in GitHub Desktop.
Elixir 1.5 supervisor problem :simple_one_for_one
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
@carlmartus
Copy link
Author

{: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]}]}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment