2006-10-28 04:04:55 +02:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : mod_proxy65.erl
|
|
|
|
%%% Author : Evgeniy Khramtsov <xram@jabber.ru>
|
|
|
|
%%% Purpose : Main supervisor.
|
|
|
|
%%% Created : 12 Oct 2006 by Evgeniy Khramtsov <xram@jabber.ru>
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
|
|
|
%%%
|
2011-02-14 13:47:22 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2011 ProcessOne
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
|
|
|
%%% This program is free software; you can redistribute it and/or
|
|
|
|
%%% modify it under the terms of the GNU General Public License as
|
|
|
|
%%% published by the Free Software Foundation; either version 2 of the
|
|
|
|
%%% License, or (at your option) any later version.
|
|
|
|
%%%
|
|
|
|
%%% This program is distributed in the hope that it will be useful,
|
|
|
|
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
%%% General Public License for more details.
|
2009-01-12 15:44:42 +01:00
|
|
|
%%%
|
2007-12-24 14:57:53 +01:00
|
|
|
%%% You should have received a copy of the GNU General Public License
|
|
|
|
%%% along with this program; if not, write to the Free Software
|
|
|
|
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
%%% 02111-1307 USA
|
|
|
|
%%%
|
2006-10-28 04:04:55 +02:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
|
|
|
-module(mod_proxy65).
|
|
|
|
-author('xram@jabber.ru').
|
|
|
|
|
|
|
|
-behaviour(gen_mod).
|
|
|
|
-behaviour(supervisor).
|
|
|
|
|
|
|
|
%% gen_mod callbacks.
|
|
|
|
-export([start/2, stop/1]).
|
|
|
|
|
|
|
|
%% supervisor callbacks.
|
|
|
|
-export([init/1]).
|
|
|
|
|
|
|
|
%% API.
|
|
|
|
-export([start_link/2]).
|
|
|
|
|
|
|
|
-define(PROCNAME, ejabberd_mod_proxy65).
|
|
|
|
|
|
|
|
start(Host, Opts) ->
|
2010-11-17 10:13:19 +01:00
|
|
|
case mod_proxy65_service:add_listener(Host, Opts) of
|
|
|
|
{error, _} = Err ->
|
|
|
|
erlang:error(Err);
|
|
|
|
_ ->
|
|
|
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
|
|
|
ChildSpec = {
|
|
|
|
Proc, {?MODULE, start_link, [Host, Opts]},
|
|
|
|
transient, infinity, supervisor, [?MODULE]
|
|
|
|
},
|
|
|
|
supervisor:start_child(ejabberd_sup, ChildSpec)
|
|
|
|
end.
|
2006-10-28 04:04:55 +02:00
|
|
|
|
|
|
|
stop(Host) ->
|
2008-10-12 13:17:35 +02:00
|
|
|
mod_proxy65_service:delete_listener(Host),
|
2006-10-28 04:04:55 +02:00
|
|
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
|
|
|
supervisor:terminate_child(ejabberd_sup, Proc),
|
|
|
|
supervisor:delete_child(ejabberd_sup, Proc).
|
|
|
|
|
|
|
|
start_link(Host, Opts) ->
|
|
|
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
|
|
|
supervisor:start_link({local, Proc}, ?MODULE, [Host, Opts]).
|
|
|
|
|
|
|
|
init([Host, Opts]) ->
|
|
|
|
Service =
|
|
|
|
{mod_proxy65_service, {mod_proxy65_service, start_link, [Host, Opts]},
|
|
|
|
transient, 5000, worker, [mod_proxy65_service]},
|
|
|
|
StreamSupervisor =
|
|
|
|
{ejabberd_mod_proxy65_sup,
|
|
|
|
{ejabberd_tmp_sup, start_link,
|
|
|
|
[gen_mod:get_module_proc(Host, ejabberd_mod_proxy65_sup),
|
|
|
|
mod_proxy65_stream]},
|
|
|
|
transient, infinity, supervisor, [ejabberd_tmp_sup]},
|
|
|
|
StreamManager =
|
|
|
|
{mod_proxy65_sm, {mod_proxy65_sm, start_link, [Host, Opts]},
|
|
|
|
transient, 5000, worker, [mod_proxy65_sm]},
|
|
|
|
{ok, {{one_for_one, 10, 1},
|
2007-06-27 13:05:14 +02:00
|
|
|
[StreamManager, StreamSupervisor, Service]}}.
|