<HTML><BODY>
Thanks for the advise about the interface.<div><br></div><div>> A normal (i.e. not simple_on_for_one) supervisor allows you to stop, restart and delete children processes, so it needs a way to identify them. Hence the id.</div><div><br></div><div>Isn't the process id the natural choice for these purposes?</div><div><br></div><div>So there is no way to avoid the need of unique ids if using anything other than simple_one_for_one?</div><div><br></div><div>Regards,</div><div><br></div><div>Martin<br><br><br><br>
-------- Оригинално писмо --------
<br>От: Mihai Balea mihai@hates.ms
<br>Относно: Re: [erlang-questions] supervisor:start_child
<br>До: Martin Dimitrov <mrtndimitrov@abv.bg>
<br>Изпратено на: Понеделник, 2011, Май 2 19:13:16 EEST
<br><br><br>
On May 2, 2011, at 8:32 AM, Martin Dimitrov wrote:<br>
<br>
> Hi,<br>
> <br>
> I am developing a server that needs to spawn (under supervision) multiple child processes. Since these processes will be of different gen_server type, I cannot use simple_one_of_one restart strategy. These servers are anonymous, I refer to them by their Pids.<br>
<br>
I think you might be able to use a simple one for one supervisor to start different types of gen_servers.<br>
You would need to create an interface module to be used in the child spec, a module that would in turn call your various other gen_servers according to some parameters.<br>
I've never done this, but I don't see why it wouldn't work.<br>
<br>
> <br>
> The problem I get is when I try to run 2 or more servers from the same type with the same id inside the child specification. I receive already_started error. By making the ids different, everything works fine.<br>
> <br>
> My question is why the id inside the child specification needs to be different for every process (even if it is of the same type)? What is the best practice to deal with this? Can the creation of dynamic ids be avoided?<br>
<br>
A normal (i.e. not simple_on_for_one) supervisor allows you to stop, restart and delete children processes, so it needs a way to identify them. Hence the id.<br>
<br>
Mihai<br></mrtndimitrov@abv.bg></div></BODY></HTML>