You can use Supervisor.which_children / 1 :
iex> Supervisor.which_children(MyApp.Supervisor) [{MyApp.SubSupervisor, #PID<0.1695.0>, :supervisor, [MyApp.SubSupervisor]}, {MyApp.Endpoint, #PID<0.1686.0>, :supervisor, [MyApp.Endpoint]}]
This function returns a list of tuples containing:
id - as defined in the specification of the child or: undefined in case of simple_user_user
child - pid of the corresponding child process, atom: restart if the process should be restarted, or: undefined if there is no such process
type -: worker or: supervisor, as defined in the specification of the child
- as defined in the child specification
Since type
and pid
provided, you can recursively extract child elements to create a list of all pids, if necessary.
source share