summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-02-09 16:25:51 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-02-09 16:25:51 +0000
commit3f2244546b15181c20fef174ec2d6fdd0d192221 (patch)
tree7484360747a505e64b0bce7de8a5e3ebdad2b6a8
parentd11305029e2d5d587b14e22cc5f04d957aa8777c (diff)
downloadrabbitmq-server-3f2244546b15181c20fef174ec2d6fdd0d192221.tar.gz
Correct the behaviour of /etc/init.d/rabbitmq-server status
-rw-r--r--docs/rabbitmqctl.1.xml18
-rw-r--r--packaging/common/rabbitmq-server.init4
-rw-r--r--src/rabbit_control.erl14
3 files changed, 33 insertions, 3 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml
index 5c090e5a..2f2e8b41 100644
--- a/docs/rabbitmqctl.1.xml
+++ b/docs/rabbitmqctl.1.xml
@@ -197,6 +197,24 @@
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><cmdsynopsis><command>init_status</command></cmdsynopsis></term>
+ <listitem>
+ <para>
+ Displays an init.d-style status line about whether the server
+ is running.
+ </para>
+ <para role="example-prefix">For example:</para>
+ <screen role="example">rabbitmqctl init_status</screen>
+ <para role="example">
+ This command displays:
+ rabbit@hostname is running (pid 1234).
+ or
+ rabbit@hostname is NOT running.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="reset">
<term><cmdsynopsis><command>reset</command></cmdsynopsis></term>
<listitem>
diff --git a/packaging/common/rabbitmq-server.init b/packaging/common/rabbitmq-server.init
index aa34fabd..f5f06887 100644
--- a/packaging/common/rabbitmq-server.init
+++ b/packaging/common/rabbitmq-server.init
@@ -79,9 +79,9 @@ stop_rabbitmq () {
status_rabbitmq() {
set +e
if [ "$1" != "quiet" ] ; then
- $CONTROL status 2>&1
+ $CONTROL init_status 2>&1
else
- $CONTROL status > /dev/null 2>&1
+ $CONTROL init_status > /dev/null 2>&1
fi
if [ $? != 0 ] ; then
RETVAL=1
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index a8903102..3f7fdf92 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -25,6 +25,7 @@
-define(QUIET_OPT, "-q").
-define(NODE_OPT, "-n").
-define(VHOST_OPT, "-p").
+-define(INHERENTLY_QUIET, [init_status]).
%%----------------------------------------------------------------------------
@@ -62,7 +63,8 @@ start() ->
end
end, Opts),
Command = list_to_atom(Command0),
- Quiet = proplists:get_bool(?QUIET_OPT, Opts1),
+ Quiet = proplists:get_bool(?QUIET_OPT, Opts1)
+ orelse lists:member(Command, ?INHERENTLY_QUIET),
Node = proplists:get_value(?NODE_OPT, Opts1),
Inform = case Quiet of
true -> fun (_Format, _Args1) -> ok end;
@@ -79,6 +81,8 @@ start() ->
false -> io:format("...done.~n")
end,
quit(0);
+ fail_silent ->
+ quit(1);
{'EXIT', {function_clause, [{?MODULE, action, _} | _]}} ->
print_error("invalid command '~s'",
[string:join([atom_to_list(Command) | Args], " ")]),
@@ -173,6 +177,14 @@ action(status, Node, [], _Opts, Inform) ->
ok
end;
+action(init_status, Node, [], Opts, _) ->
+ case call(Node, {os, getpid, []}) of
+ {badrpc, _} -> io:format("~p is NOT running.", [Node]),
+ fail_silent;
+ Res -> io:format("~p is running (pid ~s).", [Node, Res]),
+ ok
+ end;
+
action(rotate_logs, Node, [], _Opts, Inform) ->
Inform("Reopening logs for node ~p", [Node]),
call(Node, {rabbit, rotate_logs, [""]});