I am trying to input the number of nodes and start genserver processes for each of the nodes; that is each GenServer.start_link(n)
(where n
is node number) starts a separate process (PID) for each process.
pids = Enum.map(1..totalnodes, fn n ->
{:ok, unit} = GenSerModule.start_link(n)
unit
end)
The pids are returned from this line (#<12.2.2.1>
, #<12.2.2.2>
, and so on).
Now I want to start the nodes under a Supervisor. That is I must start the genserver processes through the Supervisor's init function for each node and get the PIDs. Something like this: (I know it is wrong)
pids = Enum.map(1..totalNodes, fn n ->
{:ok, unit} = worker(GenServerModule, n)
unit
end)
Supervisor.init(nodeMap,[strategy: :one_for_one])
I want to get the PIDs of started child processes in this function where I start the child processes through the Supervisor. I am stuck here.
How do I do this?