[erlang-questions] gen_server:init(Args) -> {stop, {normal, Reply}}

Guilherme Andrade g@REDACTED
Sat Sep 7 16:11:29 CEST 2019


Hello Aleksey,

You can gracefully stop a gen_server on `init` by wrapping the reason for
stopping (or a "reply") in a `{shutdown, _}` tuple, e.g.:

    init(_) ->
        {stop, {shutdown, Reason}}.

This way it won't be interpreted as a crash but still be returned to
whomever called `gen_server:start_link`.

On Mon, 2 Sep 2019 at 10:04, Aleksey Kluchnikov <kluchnikovas@REDACTED>
wrote:

> Hi
>
> look at
> https://github.com/erlang/otp/blob/maint-22/lib/stdlib/src/gen_server.erl
> line 337-371
> gen_server:init/1 hasn`t {normal, Reply} answer.
> It will be pretty good have gen_server:start/start_link normal reply
> without exit CRASH REPLY
> What do you think of it?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190907/29050fd1/attachment.htm>


More information about the erlang-questions mailing list