gen_server:init(Args) -> {stop, {normal, Reply}}

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gen_server:init(Args) -> {stop, {normal, Reply}}

Aleksey Kluchnikov
Hi

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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server:init(Args) -> {stop, {normal, Reply}}

Guilherme Andrade
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 <[hidden email]> wrote:
Hi

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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


--
Guilherme

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server:init(Args) -> {stop, {normal, Reply}}

Guilherme Andrade


On Sat, 7 Sep 2019 at 15:11, Guilherme Andrade <[hidden email]> wrote:
This way it won't be interpreted as a crash but still be returned to whomever called `gen_server:start_link`.

(Assuming that, if you're launching the gen_server under a supervisor, its child specification declares `restart` as either `transient` or `temporary`.)

 

On Mon, 2 Sep 2019 at 10:04, Aleksey Kluchnikov <[hidden email]> wrote:
Hi

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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


--
Guilherme


--
Guilherme

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions