Erlang in Practice Episode 8: OTP Supervisor and Application Behaviors

Posted in Development on November 13, 2008


Erlang in Practice Episode 8: OTP Supervisor and Application Behaviors

In this final episode, we’ll focus on two mechanisms that OTP provides to manage the lifecycle of processes in an application: supervisor and application behaviors. We’ll write a Web Supervisor and a Messaging Supervisor to manage those subsystems, and then layer another meta-supervisor on top to manage the entire chat system. You’ll learn how to:

  • implement an OTP Supervisor behavior to start, stop, and monitor worker processes
  • write child process specifications
  • handle messages sent from monitored processes
  • nest supervisors into hierarchies of supervision for better process management
  • implement an OTP Application behavior to easily start-up and gracefully shutdown an entire application
  • refactor existing code to be supervisor-friendly
  • a trick for starting Erlang systems from shell scripts, such as Unix init scripts

Watch Video

Tags: Erlang, Languages, The Pragmatic Programmers, Erlang in Practice