Simple OTP Application error

Andrea Di Persio andrea.dipersio@REDACTED
Thu Jul 2 17:56:55 CEST 2009


Hi!

I'm trying to build a simple otp application to dive deeper in erlang.

I'm following the example in Joe Armstrong 'Programmin Erlang'  and I
also tried with some example on the web but I can't make it work
correctly.

The application load correctly but when I run application:start
(appname) I get this error:

application: hda
    exited: {bad_return,
                {{hda_app,start,[normal,[]]},
                 {'EXIT',
                     {undef,
                         [{hda_app,start,[normal,[]]},
                          {application_master,start_it_old,4}]}}}}
    type: temporary
{error,{bad_return,{{hda_app,start,[normal,[]]},
                    {'EXIT',{undef,[{hda_app,start,[normal,[]]},
                                    {application_master,start_it_old,
4}]}}}}}



If I run the supervisor alone, it work correctly.



This is my   _app file:

-module(hda_app).
-behaviour(application).
-export([start/2, stop/1]).



start(_Type, _Args) ->
    hda_supervisor:start_link().


stop(_State) ->
    ok.



This is my .app file:

{application, hda,
 [{description, "Help Desk Assistant"},
  {vsn, "1.0"},
  {modules, [hda_app, hda_supervisor, customer_server,
hda_alarm_handler]},
  {registered, [customer_server]},
  {applications, [kernel, stdlib, sasl]},
  {mod, {hda_app, []}}
 ]}.


This is my supervisor:


-module(sellaprime_supervisor).
-behaviour(supervisor). % see erl -man supervisor

-export([start/0, start_in_shell_for_testing/0, start_link/1, init/
1]).



start() ->
    spawn(fun() ->
            supervisor:start_link({local,?MODULE}, ?MODULE, _Arg =
[])
    end).


start_in_shell_for_testing() ->
    {ok, Pid} = supervisor:start_link({local,?MODULE}, ?MODULE, _Arg =
[]),
    unlink(Pid).


start_link(Args) ->
    supervisor:start_link({local,?MODULE}, ?MODULE, Args).


init([]) ->
    %% Install my personal error handler
    gen_event:swap_handler(alarm_handler,
                           {alarm_handler, swap},
                           {my_alarm_handler, xyz}),
                           {ok, {{one_for_one, 3, 10},

    {ok, {{one_for_one, 3, 10},
          [{tag1,
            {customer_server, start_link, []},
             permanent,
             10000,
             worker,
             [customer_server]}
          ]}}.



Best regards,
Andrea.


More information about the erlang-questions mailing list