[erlang-questions] Need help with simple_one_for_one

Serge Aleynikov <>
Wed Aug 20 15:54:34 CEST 2008


What is the arity of erlfs_store_worker_fsm:start_link function?

Not quite sure what you mean by [] ++ 1 below.

The supervisor:start_child/2 takes a list [term()] as the second 
parameter.  Here's its docs:

"If the case of a simple_one_for_one supervisor, the child specification 
defined in Module:init/1 will be used and ChildSpec should instead be an 
arbitrary list of terms List. The child process will then be started by 
appending List to the existing start function arguments, i.e. by calling 
apply(M, F, A++List) where {M,F,A} is the start function defined in the 
child specification."

Note the A++List part.

Matt Williamson wrote:
> I'm afraid that did not work. I am passing an empty list, and if I execute
> [] ++ 1 in the shell I get 1.
> 
> On Wed, Aug 20, 2008 at 9:31 AM, Serge Aleynikov <> wrote:
> 
>> Try starting it as:
>>
>> supervisor:start_child(erlfs_store_worker_sup, [{store_chunk, Chunk}])
>>
>> The simple_one_for_one strategy appends the arguments passed to
>> supervisor:start_child/2 to the list of args specified in the supervisor's
>> spec.
>>
>> Serge
>>
>> Matt Williamson wrote:
>>
>>> Hello,
>>>
>>> I am starting a gen_fsm with
>>> supervisor:start_child(erlfs_store_worker_sup,
>>> {store_chunk, Chunk}) but I get the following error:
>>>
>>> {error,
>>>                                   {'EXIT',
>>>                                    {badarg,
>>>                                     [{erlang,
>>>                                       apply,
>>>                                       [erlfs_store_worker_fsm,
>>>                                        start_link,
>>>                                        {store_chunk,
>>>                                         {chunk,
>>>                                          {chunk_meta,
>>>                                           {file_meta,
>>>                                            "test123",
>>>                                            "test.txt",
>>>                                            0,
>>>                                            "text/plain",
>>>                                            {{0,1,1},{0,0,0}}},
>>>                                           0,
>>>                                           0,
>>>                                           []},
>>>                                          <<"Hello world!">>}}]},
>>>                                      {supervisor,do_start_child_i,3},
>>>                                      {supervisor,handle_call,3},
>>>                                      {gen_server,handle_msg,6},
>>>                                      {proc_lib,init_p,5}]}}}
>>>
>>> I've been trying to figure it out for a while, but I am having a hard
>>> time.
>>> Here is the Child Spec in the supervisor (erlfs_store_worker_sup):
>>>
>>> init(Args) ->
>>>    WorkerSpec = {erlfs_store_worker_fsm, {erlfs_store_worker_fsm,
>>>                       start_link, []},
>>>          temporary, 2000, worker, [erlfs_store_worker_fsm]},
>>>    {ok,{{simple_one_for_one, 0, 1}, [WorkerSpec]}}.
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> 
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>
> 




More information about the erlang-questions mailing list