What is a Supervisor REALLY doing?
Lennart Ohman
lennart.ohman@REDACTED
Wed Aug 30 00:19:41 CEST 2006
Hi!
> I have no book and have taken no class. I'm in
> southern california and have been fiddling with erlang
> for a month. I understand the PURPOSE of a supervisor.
> To monitor child(?) process states.
>
>
> It is not just to monitor. It is it monitor and restart processes as
> specified.
I like to add that to start with, one of the important things
with the supervisor and the hierarchy of processes you can build
is that you get a deterministic start-up of your system.
Meaning that a supervisor does not begin to start its next-in-line
child (according to the order of the children in the "children
specification") until the previous one is finished with its
"init-phase". (Being finished with the init-phase means that
the init-function of the child has returned. Note that supervisors
start their children in its init-phase).
Best Regards,
Lennart
-------------------------------------------------------------
Lennart Ohman office : +46-8-587 623 27
Sjoland & Thyselius Telecom AB cellular: +46-70-552 67 35
Sehlstedtsgatan 6 fax : +46-8-667 82 30
SE-115 28, STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED
> -----Original Message-----
> From: owner-erlang-questions@REDACTED [mailto:owner-erlang-
> questions@REDACTED] On Behalf Of Chandru
> Sent: Tuesday, August 29, 2006 8:11 PM
> To: Jeff Crane
> Cc: erlang-questions@REDACTED
> Subject: Re: What is a Supervisor REALLY doing?
>
> Hi Jeff,
>
>
> On 29/08/06, Jeff Crane <jefcrane@REDACTED> wrote:
>
> I have no book and have taken no class. I'm in
> southern california and have been fiddling with erlang
> for a month. I understand the PURPOSE of a supervisor.
> To monitor child(?) process states.
>
>
> It is not just to monitor. It is it monitor and restart processes as
> specified.
>
>
>
> This is the only implementation of Supervisor
> behaviour I can find (it's near the bottom).
>
> http://www.matt-
> mcdonnell.com/code/code_erl/erl_course/erl_course.html
>
> Is this ms.erl an accurate representation of a
> Supervisor implementation?
>
>
> Have you seen supervisor.erl in the stdlib application which comes with
> Erlang/OTP?
>
>
>
> I can't find any documentation for an erlang
> supervisor. The examples I can find on the web:
>
>
> http://www.erlang.org/doc/doc-5.5/lib/stdlib-1.14/doc/html/supervisor.html
>
>
>
> From an erlang beginner's perspective this is a
> completely uncomprehensible mechanism. For example:
>
> http://www.erlang.org/doc/doc-
> 5.4.12/doc/design_principles/sup_princ.html
>
> -module(ch_sup).
> -behaviour(supervisor). %% Why can't a I find the
> actual implementation of this behaviour, defined line
> by line so I understand what's going on?
>
> -export([start_link/0]).
> -export([init/1]).
>
> start_link() -> %% Where, when, why would I call this?
>
>
> This is called by the supervisor module. Basically, if you want a
> process to be supervised, you write a child specification. From the
> documentation, it looks like this:
>
>
> child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}
>
> Id = term()
> StartFunc = {M,F,A}
> M = F = atom()
> A = [term()]
> Restart = permanent | transient | temporary
> Shutdown = brutal_kill | int()>=0 | infinity
> Type = worker | supervisor
> Modules = [Module] | dynamic
>
> Module = atom()
>
>
>
> I can't understand how to add a supervisor without a
> solid understanding of how they work. This is one of
> many problems I have had trying to learn erlang.
>
>
> Have a read through the documentation and I'm sure it'll answer a lot of
> your questions. All OTP behaviours are part of the stdlib application.
>
> cheers
> Chandru
>
>
More information about the erlang-questions
mailing list