Use a dummy supervisor rather than rabbit_mgmt_dummy as recommended by Ulf.

This commit is contained in:
Simon MacMullen 2010-09-14 11:40:40 +01:00
parent e64680d317
commit f840450118
2 changed files with 20 additions and 67 deletions

View File

@ -21,9 +21,22 @@
-module(rabbit_mgmt_app).
-behaviour(application).
-export([start/2, stop/1]).
%% Dummy supervisor - see Ulf Wiger's comment at
%% http://erlang.2086793.n4.nabble.com/initializing-library-applications-without-processes-td2094473.html
%% All of our actual server processes are supervised by rabbit_mgmt_sup, which
%% is started by a rabbit_boot_step (since it needs to start up before queue
%% recovery or the network being up, so it can't be part of our application).
%%
%% However, we still need an application behaviour since we need to depend on
%% the rabbit_mochiweb application and call into it once it's running. Since
%% the application behaviour needs a tree of processes to supervise, this is
%% it...
-behaviour(supervisor).
-export([init/1]).
-define(PREFIX, "api").
-define(UI_PREFIX, "mgmt").
-define(SETUP_WM_TRACE, false).
@ -50,7 +63,7 @@ start(_Type, _StartArgs) ->
true -> setup_wm_trace_app();
_ -> ok
end,
rabbit_mgmt_dummy:start_link().
supervisor:start_link({local,?MODULE},?MODULE,[]).
stop(_State) ->
ok.
@ -118,3 +131,8 @@ get_port() ->
{ok, P} ->
P
end.
%%----------------------------------------------------------------------------
init([]) ->
{ok, {{one_for_one,3,10},[]}}.

View File

@ -1,65 +0,0 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License at
%% http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
%% License for the specific language governing rights and limitations
%% under the License.
%%
%% The Original Code is RabbitMQ Management Console.
%%
%% The Initial Developers of the Original Code are Rabbit Technologies Ltd.
%%
%% Copyright (C) 2010 Rabbit Technologies Ltd.
%%
%% All Rights Reserved.
%%
%% Contributor(s): ______________________________________.
%%
-module(rabbit_mgmt_dummy).
-behaviour(gen_server).
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
code_change/3]).
%% All of our actual server processes are supervised by rabbit_mgmt_sup, which
%% is started by a rabbit_boot_step (since it needs to start up before queue
%% recovery or the network being up, so it can't be part of our application).
%%
%% However, we still need an application behaviour since we need to depend on
%% the rabbit_mochiweb application and call into it once it's running. Since
%% the application behaviour needs a tree of processes to supervise, this is
%% it...
%%----------------------------------------------------------------------------
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
%%----------------------------------------------------------------------------
init([]) ->
{ok, []}.
handle_call(_Request, _From, State) ->
{reply, not_understood, State}.
handle_cast({event, Event}, State) ->
{noreply, State};
handle_cast(_Request, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Arg, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.