[erlang-questions] Adding simple process to supervisor?

Serge Aleynikov saleyn@REDACTED
Thu Oct 9 13:48:02 CEST 2008


You need to look into the proc_lib module, which serves the need you 
described.

Search this list for "proc_lib and sys"

http://www.erlang.org/pipermail/erlang-questions/2006-July/021526.html

In addition to implementing a synchronous startup function (using 
proc_lib:init_ack({ok, self()}) in your Module:start_link/1), you'll 
need to support these three functions so that your process is an 
obedient citizen in the OTP system:

	system_continue/3, system_terminate/4, system_code_change/4

E.g.:
http://www.erlang.org/pipermail/erlang-questions/2005-April/015224.html

Serge

Bengt Kleberg wrote:
> Greetings,
> 
> I have a gen_server which is supervised according to OTP rules. Now I  
> want to add a simple process that will read from a TCP port and send  
> the incoming data to the gen_server. I could spawn_link this process  
> from the gen_server and restart it if it dies. However, since I have a  
> supervisor it seems more logical to just add the process there, as a  
> rest_for_one.
> 
> 
> There is the alternative of using a supervisor_bridge, but that seems  
> more complex than using the gen_server. It seems as if I just design  
> my process according to the OTP rules I will not need to use a  
> supervisor_bridge. What are those rules? The only suggestions I have
> found are:
> 1 Module:start_link/1 => {ok, Pid}
> 2 Module:terminate/2 => ok
> 
> 
> The child specification returned by the init/1 call-back in a  
> supervisor mentions the value for Modules if we have a gen_server,  
> gen_fsm or gen_event. What could be used for a simple process?
> 
> 
> But how do I add a simple process to the supervisor? It seems overkill
> to masquerade it as a get_fsm or similar. Since it is not called from
> erlang it is not a gen_server. Since it does not have state it is not a
> gen_fsm. No events are handled.
> 
> 
> bengt
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list