[erlang-questions] Supervisor "spin rates"

Vance Shipley vances@REDACTED
Thu Apr 14 01:05:30 CEST 2011


On Wed, Apr 13, 2011 at 03:26:30PM -0700, Mike Oxford wrote:
}  That will terminate the supervisor as well, which is then restarted....

The supervisor will ignore the child.  supervisor:start_child/2
will return {ok, undefined}.

Start the supervisor:

     2> {ok, Sup} = supervisor:start_link(ignore_sup, []).
     {ok,<0.43.0>}

It has no children:

     3> supervisor:which_children(Sup).
     []

Starting the child:

     4> supervisor:start_child(Sup, []).
     
     =ERROR REPORT==== 13-Apr-2011::18:59:01 ===
     Ignoring: <0.46.0>
     {ok,undefined}

The child specification is installed:

     5> supervisor:which_children(Sup).
     [{undefined,undefined,worker,[ignore_server]}]

But the child process reported above is not alive:

     6> is_process_alive(list_to_pid("<0.46.0>")).
     false


-- 
	-Vance
-------------- next part --------------
-module(ignore_server).
-behaviour(gen_server).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

init(_) ->
	error_logger:warning_msg("Ignoring: ~w~n", [self()]),
   ignore.

handle_cast(_, State) ->
   {noreply, State}.

handle_call(_, _, State) ->
   {noreply, State}.

handle_info(_, State) ->
   {noreply, State}.

terminate(_, _) ->
	ok.

code_change(_, State, _) ->
	{ok, State}.

-------------- next part --------------
-module(ignore_sup).
-export([init/1]).
-behaviour(supervisor).

init(_StartArgs) ->
	StartMod = ignore_server,
	StartFunc = {gen_server, start_link, [StartMod, [], []]},
	ChildSpec = {StartMod, StartFunc, transient, 4000, worker, [StartMod]},
	{ok,{{simple_one_for_one, 10, 60}, [ChildSpec]}}.



More information about the erlang-questions mailing list