[ejabberd] understanding module development

mark peleus mark.peleus at gmail.com
Tue Apr 14 21:44:00 MSD 2009


Hi,

I'm trying to modify mod_rest.
I don't understand why mod_rest needs to define the supervisor:

start(_Host, _Opts) ->
    ?DEBUG("Starting: ~p ~p", [_Host, _Opts]),
    RESTSupervisor = {
      ejabberd_mod_rest_sup, {
    ejabberd_tmp_sup, start_link,
    [ejabberd_mod_rest_sup, ejabberd_mod_rest]
       },
      permanent,
      infinity,
      supervisor,
      [ejabberd_tmp_sup]
     },
    case supervisor:start_child(ejabberd_sup, RESTSupervisor) of
    {ok, _Pid} -> ok;
    {ok, _Pid, _Info} -> ok;
    {error, Error } -> {'EXIT', {start_child_error, Error}}
    end.

while mod_xmlrpc don't:

start_listener({Port, Ip}, Opts) ->
    %% get options
    MaxSessions = gen_mod:get_opt(maxsessions, Opts, 10),
    Timeout = gen_mod:get_opt(timeout, Opts, 5000),
    AccessCommands = gen_mod:get_opt(access_commands, Opts, all),

    %% start the XML-RPC server
    Handler = {?MODULE, handler},
    State = #state{access_commands = AccessCommands},
    xmlrpc:start_link(Ip, Port, MaxSessions, Timeout, Handler, State).

In addition, ejabberd wiki about http request handlers doesn't mention
supervisors
http://www.process-one.net/en/wiki/ejabberd_HTTP_request_handlers/
Is mod_rest a specific case that requires to define the supervisor?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20090414/8e88a10e/attachment.htm>


More information about the ejabberd mailing list