3 ms·
I wrote a blog post[0] that walks through some example Elixir code to explain it. It boils down to having Supervisor processes that monitors worker processes (o
by tylerpachal 9y ago
I wrote a blog post[0] that walks through some example Elixir code to explain it. It boils down to having Supervisor processes that monitors worker processes (or other supervisor processes), and the supervisor receives a message when the worker process exits. The supervisor can then decide what to do based on what the error message is.
[0] https://medium.com/@tylerpachal/let-it-crash-creating-an-example-supervisor-in-elixir-using-otp-36ea4236b02b https://medium.com/@tylerpachal/let-it-crash-creating-an-exa...
- filmor 9y agoNitpicking, in Erlang-lingo supervisors do not monitor but instead link the worker processes. This is important when the supervisor itself fails as monitors are unidirectional and would keep the (then) unsupervised processes alive while a link is bidirectional, so all workers will be killed if the supervisor goes down (and they are not explicitly trapping exits).
- tylerpachal 9y agoAwesome thanks for the info! I guess I have never really thought about the case where my supervisor would go down before the workers would. But you're right the processes are "linked" in Elixir as well.