[erlang-questions] Start A process of another node

Jayson Vantuyl kagato@REDACTED
Tue Oct 27 06:47:06 CET 2009


I'm unsure what to say here.  Erlang doesn't do this to me.

I started two nodes, one called main and one called sub.  I loaded the  
process manager on the main node.

I created a process on main using the following code:

> spawn(main@REDACTED,fun() -> receive {never,Never} -> ok after 30000 - 
> > ok end end).


It stayed around even after exiting the original node.

That says to me that something that you process does depends on the  
original node.  A few questions about your code:

1.  Does it spawn_link(), spawn_opt() with the link option, or link()  
another process?
2.  Does it do I/O?
3.  Does it generate log messages?

The second two (I/O / log messages) use the "group leader", I  
believe.  In this case, the group leader would be on the original  
node, which might cause them to exit.  Generally, I believe the group  
leader of a process should be init.  To set the group leader to init  
on the new node, try:

> group_leader( whereis(init), self() )


Note that this will affect logging, supervision trees, and IO.  If you  
want to just start/stop a remotely supervised process, I recommend  
naming its supervisor globally, and adding/removing the childspec from  
the supervisor.

On Oct 26, 2009, at 11:19 PM, maruthavanan s wrote:

>
> Hi,
>
> I need to start and stop a process on another node
>
> Say for e.g I have a main node in erlang.
>
> I have another sub node in erlang. I need to start some process in  
> main node from sub node shell.
>
> I achieved this by using the below
>
> spawn('mainnode@REDACTED',sample,start,[]).
>
> but when I close the sub node the process is stopped. Is there any  
> possibility that I can make the process live through out regardless  
> of whether I close the sub node or not, the sample:start() would be  
> running in main node?
>
> Thanks,
> Marutha
> 		 	   		



-- 
Jayson Vantuyl
kagato@REDACTED







More information about the erlang-questions mailing list