[erlang-questions] Application can not be started

Jay Doane jay@REDACTED
Wed Oct 22 23:51:17 CEST 2014


Here's a quote from the docs that T Ty mentioned:

*-s Mod [Func [Arg1, Arg2, ...]](init flag)*

Makes init call the specified function. Func defaults to start. If no
arguments are provided, the function is assumed to be of arity 0. Otherwise
it is assumed to be of arity 1, taking the list [Arg1,Arg2,...] as
argument. All arguments are passed as atoms. See init(3)
<http://erlang.org/doc/man/init.html>.
So when you pass -s application ensure_all_started dummy_proj
to erl, it's going to call application:ensure_all_started([dummy_proj])
(note that the argument is a single element list), which is not what you
want.

I struggled with the best way to deal with this for a while, and eventually
created a little helper module that looks like this:

-module(app).

%% @doc Allow applications to be started from command line: -s app start
application-name

-export([start/1]).

start([App]) ->
   application:start(App).

and seems to work well enough for my purposes. You will want to either
change the last line to application:ensure_all_started(App), or create a
separate function that calls ensure_all_started. YMMV.



On Wed, Oct 22, 2014 at 10:32 AM, 张国富 <cleancode@REDACTED> wrote:

> Thanks, it is very helpful.
> Now I added a module dummy_proj and the start function is implemented,
> finally it's working by
> $ erl -pa apps/ebin/ -boot start_sasl -s dummy_proj
>
> But personally I do not want to add a entire new module just for this
> purpose, So I tried something else.
> However, another problem shows up, that when I start erl shell by
> $ erl -pa apps/ebin/ -boot start_sasl -s application start dummy_proj
> or
> $ erl -pa apps/ebin/ -boot start_sasl -s application ensure_all_started
> dummy_proj
> Nothing will go wrong but application dummy_proj will not be started at
> the same time.
> On the other hand, if I try
> $ erl -pa apps/ebin/ -boot start_sasl -s appmon start
> the AppMon tool will be started as expected.
>
> That's to say the application:start(dummy_proj) was called, but nothing
> happened.
> It's weird.
>
> Best wishes.
> zhangguofu (Gary)
>
> 在 2014-10-22 15:13:24,"T Ty" <tty.erlang@REDACTED> 写道:
>
> According to the Erlang documentation
>
> http://erlang.org/doc/man/erl.html when you call
>
>     erl -s module
>
> And no other arguments provided it defaults to Func "start" and if no
> arguments are provided, the function is assumed to be of arity 0.
>
> On Tue, Oct 21, 2014 at 11:48 PM, Jay Doane <jay@REDACTED> wrote:
>
>> I believe this line
>>
>> {"init terminating in do_boot",{undef,[{dummy_proj,
>> start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
>>
>> indicates that the function start/0 is not defined in module dummy_proj,
>> so if you want to start it like that on the command line, you could try
>> adding something like the following to dummy_proj.erl:
>> -export([start/1]).
>> start() ->
>>     application:ensure_all_started(dummy_proj).
>>
>>
>> On Tue, Oct 21, 2014 at 1:33 PM, 张国富 <cleancode@REDACTED> wrote:
>>
>>> Hello all,
>>> I'm now following a Erlang rebar tutorial at
>>> http://www.metabrew.com/article/erlang-rebar-tutorial-generating-releases-upgrades,
>>> the test application can be started inside the erlang shell, like
>>> $ erl -pa apps/ebin/ -boot start_sasl
>>> 1> application:start(dummy_proj).
>>> =PROGRESS REPORT==== 21-Oct-2014::21:16:13 ===
>>>          application: dummy_proj
>>>           started_at: nonode@REDACTED
>>> ok
>>> 2> dummy_proj_server:poke().
>>> {ok,1}
>>> but it can not be started this way
>>> $ erl -pa apps/ebin/ -boot start_sasl -s dummy_proj
>>> Erlang R16B03 (erts-5.10.4) [source] [smp:4:4] [async-threads:10]
>>> [kernel-poll:false]
>>> .... <skip> .....
>>> =PROGRESS REPORT==== 21-Oct-2014::21:17:23 ===
>>>          application: sasl
>>>           started_at: nonode@REDACTED
>>> {"init terminating in
>>> do_boot",{undef,[{dummy_proj,start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
>>> Crash dump was written to: erl_crash.dump
>>> init terminating in do_boot ()
>>>
>>> It seems Erlang is trying to call dummy_proj:start(), but I can not
>>> understand why.
>>> Anybody who ever encountered the same problem here? How can I make it
>>> work?
>>>
>>> Thanks.
>>>
>>> Best wishes
>>>
>>> zhangguofu(Gary)
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 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/20141022/ac3f70ae/attachment.htm>


More information about the erlang-questions mailing list