[erlang-questions] Match Made In Heaven: proc_lib:spawnlink(Node, M, F, A) & gen_server:call({global, ?SERVER}, a marriage?

db <>
Tue Apr 22 05:01:18 CEST 2008


If anyone of OTP's gen_* spawns a process on a remote machine using
proc_lib:spawn_link(Node, M, F, A), and supervisor terminates the
gen_*, then do I have to explicitly catch the termination signal  from
the gen_*  within the process spawned by the proc_lib:spawn_link(Node,
M, F, A) like so?

receive
        ...
         {'EXIT', Parent, Reason} ->
             ..maybe some cleaning up here..
             exit(Reason);
         ...
     end.

Or does a remotely spawned proc_lib process also get terminated by
OTP's gen_* whenever supervisor terminates any one of the OTP's gen_*?

On Mon, Apr 21, 2008 at 7:27 PM, db <> wrote:
> I have a global gen_server on nodeA and the clients are spawned on
>  remote nodes(B,C,...) from nodeA by a another gen_server. Common
>  supervisor that supervise both gen_server for client and global
>  gen_server on NodeA.
>
>  nodeA
>     |-supervisor
>           |-global_gen_server
>           |-client_gen_server (this gen_server uses
>  proc_lib:spawn_link(Node, M, F, A) to spawn clients on remote nodes
>  and respawn client onto remote nodes if they die).
>
>  If the supervisor on nodeA sends terminate signal to global_gen_server
>  and client_gen_server, I need the remote clients to also die.
>
>  I use proc_lib to spawn the client on remote node.
>  Proc_lib:spawn_link(Node, M, F, A) has looping structure as follows:
>
>  loop(...) ->
>     receive
>         ...
>
>         {'EXIT', Parent, Reason} ->
>             ..maybe some cleaning up here..
>             exit(Reason);
>         ...
>     end.
>
>  How can I call gen_server:call({global, ?SERVER} inside this loop, so
>  that the reply from the gen_server hits one of the receive condition.
>  Is proc_lib:spawn_link and gen_server:call({global, ?SERVER} a match
>  made in heaven or I have to go with proc_lib:spawn_link and
>  gen_server:cast({global, ?SERVER}?
>
>  Thank you.
>  --
>  rk
>
>  That which we persist in doing becomes easier for us to do; not that
>  the nature of the thing itself is changed, but that our power to do is
>  increased.
>  -Ralph Waldo Emerson
>



-- 
rk

That which we persist in doing becomes easier for us to do; not that
the nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson



More information about the erlang-questions mailing list