Starting processes at remote nodes

Vance Shipley vances@REDACTED
Fri Jun 4 20:34:18 CEST 2004


Is there a good reason why we don't have a proc_lib function
to synchronously start a process on a remote node?

Am I being naive about how well this works?


You can spawn a process on a remote node like this:

(foo@REDACTED)3> spawn('bar@REDACTED', io, fwrite, ["Hello World!~n"]).
Hello World!

The proc_lib library supplies it's own version:

(foo@REDACTED)4> proc_lib:spawn('bar@REDACTED', io, fwrite, ["Hello World!~n"]).
Hello World!

The generic behaviours in OTP are started synchronously using 
proc_lib:start_link/5.  When you run gen_server:start_link/3 your
process will execute proc_lib:start_link/5 to start the process
with gen_server:init_it/6.  This new process runs proc_lib:init_ack/2
to signal the calling process of the result.  Your process now
returns the result ({ok, Pid}).  

(foo@REDACTED)1> proc_lib:start_link(gen_server, init_it, [self(), self(), self(), server, [], []]).


New functions:

	proc_lib:start(Node, M,F,A,Timeout,SpawnOpts)

We should add the same capability to the generic behaviours.

New functions:

	gen_server:start_link(Node, Name, Mod, Args, Options)
	gen_fsm:start_link(Node, Name, Mod, Args, Options)
	supervisor:start_link(Node, Name, Mod, Args)

	%%%    Node ::= node()

Extend the definition of Name to include none:

	%%%    Name ::= {local, atom()} | {global, atom()} | none


Automatically distribute processes across several nodes.

For example:


init(_Args) ->
   StartArgs = [fsm, [], []],
   StartFunc = {start_link, start_link, StartArgs},
   ChildSpec = {fsm, StartFunc, transient, 4000, worker, [fsm]},
   {ok, {{simple_one_for_one, 10, 60}, [ChildSpec]}}.


start_link(Mod, Arg, Opt, Node) ->
   gen_fsm:start_link(Node, none, Mod, Arg, Opt).

(foo@REDACTED)3> supervisor:start_child(SupRef, [pool:get_node()]).
{ok, <4183.43.0>}


Vance Shipley
Motivity Telecom Inc.
+1 519 240 3684

More information about the erlang-questions mailing list