[erlang-questions] application startup failure?

Scott Lystig Fritchie <>
Tue Nov 23 05:11:06 CET 2010


Andy Kriger <> wrote:

ak> Or maybe there's a better way to handle this situation?

Andy, would it be awful to simply call error_logger:error_msg() or
similar in your app's init() function before it returns {error, Reason}?

If you have the sasl application already running, then you should also
get both a crasher report and an info report that contain the returned
reason.  Code follows the messages.  Comparing info reports, it looks
like your app's Reason term really is 'shutdown'?  {shrug}

-Scott

1> application:start(sasl).
ok
2> application:start(foo).
{error,{yofoo,{foo,start,[normal,[]]}}}

=ERROR REPORT==== 22-Nov-2010::22:05:20 ===
foo:start type normal args []

=CRASH REPORT==== 22-Nov-2010::22:05:20 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.47.0>
    registered_name: []
    exception exit: {yofoo,{foo,start,[normal,[]]}}
      in function  application_master:init/4
    ancestors: [<0.46.0>]
    messages: [{'EXIT',<0.48.0>,normal}]
    links: [<0.46.0>,<0.6.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 233
    stack_size: 24
    reductions: 102
  neighbours:

=INFO REPORT==== 22-Nov-2010::22:05:21 ===
    application: foo
    exited: {yofoo,{foo,start,[normal,[]]}}
    type: temporary

--- snip --- snip --- snip --- snip --- snip --- snip --- snip --- 

%% foo.erl

-module(foo).
-author('').

-behaviour(application).

-export([start/2, stop/1]).

start(Type, StartArgs) ->
    error_logger:error_msg("~s:start type ~p args ~p\n", [?MODULE, Type,
    StartArgs]),
    {error, yofoo}.

stop(State) ->
    ok.

--- snip --- snip --- snip --- snip --- snip --- snip --- snip --- 

%% foo.app

{application, foo,
 [{description, "foo app"},
  {vsn, "99"},
  {modules, [ foo
              ]},
  {registered, []},
  {applications, [kernel,
                  stdlib,
                  sasl]},
  {mod, { foo, []}},
  {env, []}
]}.


More information about the erlang-questions mailing list