[erlang-questions] How to force kernel application will always be started before my app

Oscar Hellström oscar@REDACTED
Mon Nov 24 13:58:48 CET 2008


Hi,

You probably want to create a custom boot script for your application
rather than using the start_sasl one.

You could check out
http://erlang.org/doc/design_principles/release_structure.html#10 and
see how releases, start scripts and release packages can be built.

Sergey A. wrote:
> Hello.
> 
> I've a tricky problem with starting my OTP application from escript interface.
> 
> Here is what I do in escript to start my app:
> 
> First I start a node for my application:
> 
> RunNode = "erl -detached -sname foo@REDACTED -setcookie my_cookie
> -boot start_sasl -config log -pa /path/to/ebin",
> os:cmd(RunNode)
> 
> Then my script waits until the node is actually started:
> 
> wait_for(pong, foo@REDACTED),
> 
> after that I do rpc:call to start my application and check if there
> was an error (that is why I don't use "erl -s foo start". I need to
> know in my escript whether app was started or not):
> 
> case rpc:call(foo@REDACTED, foo, start, []) of
>         ok -> ok;
>         {error, Reason} ->
>             erlang:error(internal_foo_error)
> end
> 
> But at some computers such a rpc:call fails with {error,
> {not_started,kernel}} return value. This happens because kernel
> application doesn't have enough time between os:cmd and rpc:call calls
> to start.
> 
> What I should do to avoid this error in a right manner?
> 
> I think that using of timer:sleep(300) isn't the right way.
> 
> I could use somethin like
> 
> [rpc:call(foo@REDACTED, application, start, [App]) || App <- [kernel, sasl]]
> 
> in escript before starting my application, but it looks like a hack
> (or not?). I beleive there should be the standard way to ensure that
> all the dependencies of my app were already started.
> 
> It's my foo.app:
> 
> {application, foo,
>  [{description, "Foo"},
>   {vsn, "1.0"},
>   {modules, [<skipped>]},
>   {registered, [foo_storage, foo_sup, foo_web]},
>   {applications, [kernel, stdlib, sasl]},
>   {mod, {gin_app, []}}
> ]}.
> 
> Thanks.
> 
> --
> Sergey.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

Best regards
-- 
Oscar Hellström, oscar@REDACTED
Office: +44 20 7655 0337
Mobile: +44 798 45 44 773
Erlang Training and Consulting
http://www.erlang-consulting.com/



More information about the erlang-questions mailing list