What is a Supervisor REALLY doing?
Jeff Crane
jefcrane@REDACTED
Tue Aug 29 18:22:37 CEST 2006
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.
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?
I can't find any documentation for an erlang
supervisor. The examples I can find on the web:
http://wiki.trapexit.org/index.php/A_fast_web_server_demonstrating_some_undocumented_Erlang_features#Supervisor_and_Application_implementation
(and with some digging, some others that are very
similar to this example).
>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?
All I know is that it starts the supervisor...I think
supervisor:start_link(ch_sup, []). %% Where did
start_link/2 come from?
init(_Args) -> %% How and when is this called?
{ok, {{one_for_one, 1, 60}, %% I have no idea
what's returning this or what the values are for
[{ch3, {ch3, start_link, []},
permanent, brutal_kill, worker, [ch3]}]}}.
%% I cannot understand what is going on here
When I have my own program, where I
start().
receiveLoop([]) ->
Pid = spawn child,
add_Pid_to_list(Pid,[]),
receiveLoop.
child ->
do stuff,
child().
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.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the erlang-questions
mailing list