[erlang-questions] application starting in releases

33 views
Skip to first unread message

Roberto Ostinelli

unread,
Oct 14, 2012, 5:29:48 PM10/14/12
to Erlang
Dear list,

AFAIK a release will start the dependency applications defined in an application .app file. So for instance, if I specify:

{application, myapp, [
{description, ""},
{vsn, "0.1-dev"},
{modules, []},
{registered, [
]},
{applications, [
kernel,
stdlib,
compiler,
syntax_tools,
lager
]},
{mod, {myapp, []}},
{env, []}
]}.

When I package all of this as a release, all of the specified applications will be started automatically when I launch myapp. Is this correct?

If so, I want to have a developer start script that starts these applications manually, to emulate what the release will launch for me: I do not want to have extra application:start(compiler) code in myapp, since I won't need that once it's packaged.

So I'm using this:

erl -pa apps/*/ebin -pa deps/*/ebin \
-boot start_sasl \
-config app \
-s application start compiler
-s myapp

However compiler does not start:

1> application:which_applications().
[{sasl,"SASL  CXC 138 11","2.2.1"},
 {stdlib,"ERTS  CXC 138 10","1.18.2"},
 {kernel,"ERTS  CXC 138 10","2.15.2"}]

But if I manually start it:

2> application:start(compiler).
ok

Is there something I'm doing wrong? Am I actually supposed to use application:start/1 in myapp anyways?

Thank you,

r.

fr...@circlewave.net

unread,
Oct 14, 2012, 5:45:26 PM10/14/12
to Roberto Ostinelli, Erlang
On Sun, Oct 14, 2012 at 02:29:48PM -0700, Roberto Ostinelli wrote:
> If so, I want to have a developer start script that starts these
> applications manually, to emulate what the release will launch for me: I do
> not want to have extra application:start(compiler) code in myapp, since I
> won't need that once it's packaged.
>
> So I'm using this:
>
> erl -pa apps/*/ebin -pa deps/*/ebin \
> -boot start_sasl \
> -config app \
> -s application start compiler

This ends up doing "application:start([compiler])" which returns an error,
init(3) probably ignores return value as it couldn't really know what to
expect. Try with -eval instead:

erl -boot start_sasl -eval 'application:start(compiler).'

BTW I vaguely recall rebar can do this for you somehow?

> Am I actually supposed to use application:start/1 in myapp anyways?

No, it's quite rare to do that, the only use case I've seen is bringing
protocol stacks up and down manually depending on availability of some
backend connections (well, lazy man's way to do that anyway).

BR,
-- Jachym
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Roberto Ostinelli

unread,
Oct 14, 2012, 6:57:17 PM10/14/12
to fr...@circlewave.net, Erlang
This ends up doing "application:start([compiler])" which returns an error,
init(3) probably ignores return value as it couldn't really know what to
expect. Try with -eval instead:

  erl -boot start_sasl -eval 'application:start(compiler).'

Oh I see. I wanted to avoid `eval` for some reason, but this works perfectly. Thank you.
 

BTW I vaguely recall rebar can do this for you somehow?

No idea. Tuncer? :)
 

> Am I actually supposed to use application:start/1 in myapp anyways?

No, it's quite rare to do that, the only use case I've seen is bringing
protocol stacks up and down manually depending on availability of some
backend connections (well, lazy man's way to do that anyway).

Ok this is exactly what I thought.

Again, thank you,

r.
 

Tuncer Ayaz

unread,
Oct 15, 2012, 4:19:35 PM10/15/12
to Roberto Ostinelli, Erlang
On Mon, Oct 15, 2012 at 12:57 AM, Roberto Ostinelli wrote:
> This ends up doing "application:start([compiler])" which returns an error,
> >
> > init(3) probably ignores return value as it couldn't really know
> > what to expect. Try with -eval instead:
> >
> > erl -boot start_sasl -eval 'application:start(compiler).'
>
>
> Oh I see. I wanted to avoid `eval` for some reason, but this works
> perfectly. Thank you.
>
>
> > BTW I vaguely recall rebar can do this for you somehow?
>
>
> No idea. Tuncer? :)

This is most likely referring to the release support and
scripts/templates.

> > > Am I actually supposed to use application:start/1 in myapp
> > > anyways?
> >
> > No, it's quite rare to do that, the only use case I've seen is
> > bringing protocol stacks up and down manually depending on
> > availability of some backend connections (well, lazy man's way to
> > do that anyway).
>
>
> Ok this is exactly what I thought.
>
> Again, thank you,
Reply all
Reply to author
Forward
0 new messages