Listing all processes (pids)?

488 views
Skip to first unread message

Nytz12

unread,
Jan 7, 2016, 1:20:41 AM1/7/16
to elixir-lang-talk
Hi

I would like to be able to track the state of all my spawned agents.

Is there any way to list all pids in Elixir?


José Valim

unread,
Jan 7, 2016, 3:03:11 AM1/7/16
to elixir-l...@googlegroups.com
If you want to track them, you should put them in a supervisor and traverse the supervisor. You can use Process.list and Process.registered to retrieve processes but it will retrieve all processes *in the system*.



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/760faff5-eb2a-4da3-8b0b-eb4b7a855cfd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nytz12

unread,
Jan 8, 2016, 1:45:30 AM1/8/16
to elixir-lang-talk, jose....@plataformatec.com.br
I see

When I set up a supervisor, it is started with the application and defines a number of worker processes to watch. However, I am not sure how to dynamically add new processes to a supervisor.

Usually 

Peter Hamilton

unread,
Jan 8, 2016, 2:59:41 AM1/8/16
to elixir-lang-talk, jose....@plataformatec.com.br

Supervisor.start_child allows you to dynamically add workers to a supervisor.

However, you likely want to use simple_one_for_one as the strategy for the supervisor. Instead of giving it a list of workers when starting it, you give it a blueprint for each dynamic worker. You then call Supervisor.start_child and just pass a few arguments, which are appended to the ones in the blueprint already provided.


Reply all
Reply to author
Forward
0 new messages