[erlang-questions] patterns or best practices to shut applications down?

PAILLEAU Eric eric.pailleau@REDACTED
Sat Dec 23 16:06:52 CET 2017

in addition to other answers, it is worth noting that you can set
a maximum time to VM to stop.


"To limit the shutdown time, the time init is allowed to spend taking 
down applications, command-line flag -shutdown_time is to be used."

this can be very useful when some processes are stuck in abnormal 
terminate work. But using this you can loose data obviously.
Restart time is sometime more important than loosing some cleanup.


Le 23/12/2017 à 15:41, Fred Hebert a écrit :
> On 12/23, Xavier Noria wrote:
>> But there's something that bugs me and prevents me from imagining 
>> complete
>> and round solutions, which is shutting down. When shutting down (think
>> autoescaling, deploys, etc.). I have a live system that needs to stop
>> orderly.
>> Are there patterns or best practises about how to design this aspect 
>> of the
>> system?
> Good news! You already have this covered with OTP.
> When shutting down a supervision tree, the supervisor will send down a 
> `shutdown` exit signal to each of its children in order. A child 
> supervisor will trap exit on this, and forward it to its own children 
> first.
> If your worker has nothing special to do, just let it die. If it needs 
> some special cleanup, trap exit in the worker and `terminate` will be 
> called.
> So the supervision structure you have that tells how the program boots 
> also tells how it shuts down. You do have to be careful about the 
> handling of timeouts though (or brutal_kill will catch you up).
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list