Terminating application during startup
Serge Aleynikov
serge@REDACTED
Wed Mar 22 14:51:04 CET 2006
How would you recommend to deal with a problem when there's a syntax
error in the application's config file? It get's parsed before the call
to start/2.
Serge
Gunilla Arendt wrote:
> Then let your application recognize that it cannot start,
> print out an error message and call erlang:halt(N) with an appropriate
> error code N.
>
> --------------
> -module(my).
>
> -export([start/2]).
>
> start(normal, [foo]) ->
> io:format("Cannot start due to whatever~n", []),
> erlang:halt(1).
> ---------------
>
> % erl -boot my -noshell
> Cannot start due to whatever
> %
>
>
> Regards, Gunilla
>
> Fredrik Thulin wrote:
>
>> On Wednesday 22 March 2006 10:42, Gunilla Arendt wrote:
>>
>>> Hi,
>>>
>>> This bug is fixed in OTP R11B.
>>
>>
>> Thanks.
>>
>>> I'm not quite sure what you mean with "terminating nicely". If you
>>> mean that you want the node to survive even if an application fails
>>> to start, set the type of the application to transient in the .rel
>>> file.
>>
>>
>> I'm using Erlang to write a SIP-server that I want to make work like
>> most other server softwares people are used to, so that it can be used
>> without any knowledge about Erlang, beam, Mnesia and so on, just
>> regular system administration skills.
>>
>> In my opinion, this means that if certain fatal errors occur during
>> startup, the Erlang VM (whole node) should terminate with
>> * a nice and understandable error message on standard output
>>
>> and
>>
>> * a non-zero exit status so that people can start the server from a
>> shellscript and know if it failed or succeeded.
>>
>> Also, the generation of erl_crash.dump should be avoided when I (as
>> programmer) don't think it is needed (for example, the server could be
>> started in a just-test-the-config-syntax mode).
>>
>> /Fredrik
More information about the erlang-questions
mailing list