January 2013
Beginner to intermediate
624 pages
17h 18m
English
Supervisors are one of the most useful parts of OTP. We’ve encountered basic supervisors in Chapter 12 and Chapter 13, where they offered a way to keep our software going in case of errors by just restarting the faulty processes. This chapter introduces OTP’s take on supervisors, which is much better than ours.
In our earlier examples, our supervisors would start a worker process, link to it, and trap exit signals with process_flag(trap_exit,true) to know when the process died and restart it. This is fine when we want restarts, but it’s also pretty dumb. Imagine that you’re using the remote control to turn on the TV. If it doesn’t work the first time, you might try again once or twice, just in case you ...
Read now
Unlock full access