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