summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-11-08 16:20:26 +0000
committerSimon MacMullen <simon@rabbitmq.com>2012-11-08 16:20:26 +0000
commit46e4a2b5ac16428e69be16e6fd61632885dc5ef1 (patch)
tree4d83ae10112d6181127caf232ad90cd7f24705fe
parentc5a64acac12ba209f07d06c3316847c3f9c6e137 (diff)
downloadrabbitmq-server-46e4a2b5ac16428e69be16e6fd61632885dc5ef1.tar.gz
Make the app marker into a gen_server
-rw-r--r--src/rabbit.erl18
-rw-r--r--src/rabbit_app_marker.erl41
2 files changed, 44 insertions, 15 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 8c13224f..66adcca3 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -21,7 +21,7 @@
-export([start/0, boot/0, stop/0,
stop_and_halt/0, await_startup/0, status/0, is_running/0,
is_running/1, environment/0, rotate_logs/1, force_event_refresh/0,
- start_fhc/0, start_app_marker/1, hibernate/0]).
+ start_fhc/0]).
-export([start/2, stop/1]).
@@ -176,7 +176,8 @@
-rabbit_boot_step({app_running,
[{description, "cluster membership"},
- {mfa, {rabbit, start_app_marker, [boot]}},
+ {mfa, {rabbit_sup, start_restartable_child,
+ [rabbit_app_marker]}},
{requires, networking}]}).
-rabbit_boot_step({notify_cluster,
@@ -775,16 +776,3 @@ start_fhc() ->
rabbit_sup:start_restartable_child(
file_handle_cache,
[fun rabbit_alarm:set_alarm/1, fun rabbit_alarm:clear_alarm/1]).
-
-start_app_marker(boot) ->
- supervisor:start_child(rabbit_sup,
- {rabbit_app, {?MODULE, start_app_marker, [spawn]},
- transient, ?MAX_WAIT, worker, [?MODULE]});
-start_app_marker(spawn) ->
- Pid = spawn_link(fun() -> erlang:hibernate(?MODULE, hibernate, []) end),
- register(rabbit_running, Pid),
- {ok, Pid}.
-
-hibernate() ->
- erlang:hibernate(?MODULE, hibernate, []).
-
diff --git a/src/rabbit_app_marker.erl b/src/rabbit_app_marker.erl
new file mode 100644
index 00000000..14daa98c
--- /dev/null
+++ b/src/rabbit_app_marker.erl
@@ -0,0 +1,41 @@
+%% 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.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
+%%
+
+-module(rabbit_app_marker).
+
+-behaviour(gen_server).
+
+-export([start_link/0]).
+
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
+ terminate/2, code_change/3]).
+
+-include("rabbit.hrl").
+
+start_link() ->
+ gen_server:start_link({local, rabbit_running}, ?MODULE, [], []).
+
+%%----------------------------------------------------------------------------
+
+init([]) -> {ok, state, hibernate}.
+
+handle_call(_Msg, _From, State) -> {stop, not_understood, State}.
+handle_cast(_Msg, State) -> {stop, not_understood, State}.
+handle_info(_Msg, State) -> {stop, not_understood, State}.
+
+terminate(_Arg, _State) -> ok.
+
+code_change(_OldVsn, State, _Extra) -> {ok, State}.