4 ms·
Disclaimer: I have almost no experience with Erlang/OTP. But the question here is not whether you can implement different kinds of shutdown, it's rather which
by rumcajz 8y ago
Disclaimer: I have almost no experience with Erlang/OTP.
But the question here is not whether you can implement different kinds of shutdown, it's rather which kind covers the common graceful shutdown use cases.
If Erlang/OTP has such algorithm, I'd love to hear about it.
- _asummers 8y agoErlang has an explicit concept of processes and supervisors,and communication by message passing. When a worker process dies, the supervisor is made aware of it, and upon receipt of the message, can decide what to do. In some cases that means restarting the worker to some known good state (turn it off and on), in others just restarting a generic worker (a web server, for example), and others, the supervisor cannot recover on its own so it crashes itself and lets its own supervisor do the same exercise. It also has a notion of hot code reloading, which can go and change process state to satisfy the new software requirements of the new app version (think upgrading a telephone pole remotely).
- rumcajz 8y agoI meant it the other way round. The question was not about what happens when the child dies. It was rather how does the parent let the child know that it should terminate. Or that it should eventually terminate, but that it should attempt a clean shut down.
- _asummers 8y agoThe supervisor can also terminate its children. The communication goes both ways. But the children may also be supervisors with their own children. which all have their own termination behavior. The VM is designed around reliability and addresses this sort of behavior with language constructs.
- rumcajz 8y agoOk, I guess I'll have to give it a closer look. But are you positive they have a good story about interactions between hard and soft shutdowns? E.g. when grandparent requests a hard shutdown but parent a soft shutdown. Or vice versa. Or if timeouts of cancellations on different level of the hierarchy don't match?
- _asummers 8y agoIt was designed for dealing with telephone switches, which could go offline for any reason, and need to be worked around. I recommend the entirety of LYSE, but [0] this chapter should give you some footing. To your specific question, upon receipt of the DOWN message, the processes can respond according to what makes sense to the domain. [0] https://learnyousomeerlang.com/supervisors https://learnyousomeerlang.com/supervisors
- rumcajz 8y agoThanks!