[erlang-questions] dumb question from rookie

Ryan Huffman ryanhuffman@REDACTED
Tue Mar 6 07:21:47 CET 2012


It looks like you are trying to call your state function with 0 arguments, but the start function has an arity of 2 (it expects 2 arguments).  You can add 2 dummy arguments or use `-s application start mysample` instead.

On Monday, March 5, 2012 at 10:07 PM, envelopes envelopes wrote:

> 
> I have a sample program generated from rebar
> 
> 1. mysample_app.erl
> 
> -module(mysample_app).
> 
> -behaviour(application).
> 
> %% Application callbacks
> -export([start/2, stop/1, main/1]).
> 
> %% ===================================================================
> %% Application callbacks
> %% ===================================================================
> 
> start(_StartType, _StartArgs) ->
>     mysample_sup:start_link().
> 
> stop(_State) ->
>     ok.
> 
> 
> main([A]) ->
> I = list_to_integer(atom_to_list(A)),
> F = fac(I),
> io:format("factorial ~w = ~w~n" ,[I, F]),
> init:stop().
> fac(0) -> 1;
> fac(N) -> N*fac(N-1).
> 
> 
> 2. mysample_sup.erl
> 
> 
> -module(mysample_sup).
> 
> -behaviour(supervisor).
> 
> %% API
> -export([start_link/0]).
> 
> %% Supervisor callbacks
> -export([init/1]).
> 
> %% Helper macro for declaring children of supervisor
> -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
> 
> %% ===================================================================
> %% API functions
> %% ===================================================================
> 
> start_link() ->
>     supervisor:start_link({local, ?MODULE}, ?MODULE, []).
> 
> %% ===================================================================
> %% Supervisor callbacks
> %% ===================================================================
> 
> init([]) ->
>     {ok, { {one_for_one, 5, 10}, []} }.
> 
> 
> 3) the problem.
> erl -pa ebin -s mysample_app main 23  ===> worked fine
> erl -pa ebin -s mysample_app start   ===> crashed on boot.
> 
> {"init terminating in do_boot",{undef,[{mysample_app,start,[],[]},{init,start_it
> ,1,[{file,"init.erl"},{line,1042}]},{init,start_em,1,[{file,"init.erl"},{line,10
> 22}]}]}}
> 
> Crash dump was written to: erl_crash.dump
> init terminating in do_boot ()
> 
> what is the cause ? my erlang is the latest R15.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED (mailto:erlang-questions@REDACTED)
> http://erlang.org/mailman/listinfo/erlang-questions
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120305/6bbd8a4e/attachment.htm>


More information about the erlang-questions mailing list