If I run the first part of the code (Up to “After creation…”) on node 1, here is what I see:
iex(n0@127.0.0.1)17> iex(n0@127.0.0.1)17> IO.inspect(Horde.DynamicSupervisor.which_children(:root_supervisor), pretty: true)
[
{:undefined, #PID<0.2971.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.2978.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.2985.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.2992.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.2999.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.3006.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.3013.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.3020.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.3027.0>, :worker, [Horde.DynamicSupervisor]},
{:undefined, #PID<0.3034.0>, :worker, [Horde.DynamicSupervisor]}
]
...
And then I try to terminate a child using the supervisor name, it works:
iex(n0@127.0.0.1)18> Horde.DynamicSupervisor.terminate_child(:root_supervisor, pid(0, 3034, 0))
:ok
But, the other node can’t see the supervisor at all:
iex(n1@127.0.0.1)3> IO.inspect(Horde.DynamicSupervisor.which_children(:root_supervisor), pretty: true)
** (exit) exited in: GenServer.call(:root_supervisor, :which_children, :infinity)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
(elixir 1.14.3) lib/gen_server.ex:1027: GenServer.call/3
iex:3: (file)
iex(n1@127.0.0.1)3> Horde.DynamicSupervisor.terminate_child(:root_supervisor, pid(0, 3027, 0))
** (exit) exited in: GenServer.call(:root_supervisor, {:terminate_child, #PID<0.3027.0>}, :infinity)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
(elixir 1.14.3) lib/gen_server.ex:1027: GenServer.call/3
iex:3: (file)
iex(n1@127.0.0.1)3>
Hence the desire to use pids and not names


















