[erlang-questions] supervisor creation

Ulf Wiger ulf.wiger@REDACTED
Wed May 6 16:48:55 CEST 2009


Gamoto wrote:
> Thank you. Does it mean that an application can be distributed on
> several nodes, even if the nodes are on the same machine ? If yes,
> what is the benefit ?

It's analogous to how gen_servers can be registered either
locally or globally. I've personally not heard of anyone
who makes use of globally registered supervisors, but the
feature is there mainly because supervisor is built on
gen_server, and gen_server supports the option of global
name registration (which it does because the undocumented
module gen.erl supports it.)

It doesn't mean that the application gets distributed,
only that it becomes possible to call functions like
supervisor:which_children({global, SupName}) from anywhere
in a cluster.

BR,
Ulf W



>> # Gamoto 2009-05-06:
>>> One of the syntax for the creation of a supervisor process is:
>>> 
>>> start_link(SupName, Module, Args) ->> Result         with
>>> SupName = {local, Name} | {global, Name}
>>> 
>>> The manual says:
>>> 
>>> If SupName={local, Name} the supervisor is registered locally as
>>> Name using register/2. If SupName={global, Name} the  supervisor 
>>> is  registered globally as Name using global:register_name/2. If
>>> no name is provided, the supervisor is not registered.
>>> 
>>> What does it means ? registered locally ? consequence ?
>>> advantages ? registered globally ? etc ...
>> Registered locally:
>> 
>> You can use Name::atom() to talk to the supervisor instead of a
>> pid(). The alias only works on current node.
>> 
>> Registered globally:
>> 
>> Like above, but the alias works on every node in your cluster. See
>> also global(3).
>> 
>>> The .app file of an application has already a "registered field"
>>> !
>> From app(3): registered: All names of registered processes started
>> in  this  application. systools  uses this list to detect name
>> clashes between different applications.
>> 
>> IOW this just declares registered names your application is using.
>> 
>> -- Jachym
> 
> _______________________________________________ erlang-questions
> mailing list erlang-questions@REDACTED 
> http://www.erlang.org/mailman/listinfo/erlang-questions


-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com



More information about the erlang-questions mailing list