[erlang-questions] starting of two instances of server

Magnus Henoch magnus@REDACTED
Fri May 22 20:09:48 CEST 2009


"info" <info@REDACTED> writes:

> init()->
> Spec1= {id1, generic, start_link, [par1_1,par2_1],permanent,
> brutal_kill,worker, [generic]},
> Spec2= {id2, generic, start_link, [par1_2,par2_2],permanent,
> brutal_kill,worker, [generic]},

The module, function and argument terms should be embedded in a tuple:

Spec1= {id1, {generic, start_link, [par1_1,par2_1]},permanent,
        brutal_kill,worker, [generic]},
Spec2= {id2, {generic, start_link, [par1_2,par2_2]},permanent,
        brutal_kill,worker, [generic]},

> Childs= [Spec1,Spec2],
> case supervisor:check_childspecs(Childs) of
> {ok} ->

That should be "ok" instead of "{ok}" - see the documentation of
check_childspecs at http://erlang.org/doc/man/supervisor.html .

>     SChilds={{one_for_one,2,10},Childs),
>     {ok,SChilds};
> {error,Reason} ->
>     io:format("Error: ~s~n", [Reason]),

And that should be "~p" instead of "~s", since Reason will not be a
string, but any term.

I can't really explain the error message you get, though - it seems you
get _both_ a badarg for the format string _and_ a case_clause for the
{ok}, but that doesn't make sense.  (Most likely I'm misreading
something...)

-- 
Magnus Henoch, magnus@REDACTED
Erlang Training and Consulting
http://www.erlang-consulting.com/




More information about the erlang-questions mailing list