summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-10-25 15:45:13 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-10-25 15:45:13 +0100
commit95a7ba33b5177763a52d74380fe80b807ee03191 (patch)
treecbfd119a6701ec88beea6a5b6cf5f2c16dd49446
parentf0bbbe6f7508166210563ba405967ab397b9d899 (diff)
downloadrabbitmq-server-95a7ba33b5177763a52d74380fe80b807ee03191.tar.gz
rebase on default
-rw-r--r--docs/rabbitmqctl.1.xml8
-rw-r--r--packaging/common/rabbitmq-server.init2
-rw-r--r--src/rabbit_control.erl18
3 files changed, 26 insertions, 2 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml
index 662a36c7..f21888bd 100644
--- a/docs/rabbitmqctl.1.xml
+++ b/docs/rabbitmqctl.1.xml
@@ -103,7 +103,7 @@
<variablelist>
<varlistentry>
- <term><cmdsynopsis><command>stop</command></cmdsynopsis></term>
+ <term><cmdsynopsis><command>stop</command> <arg choice="opt"><replaceable>pid_file</replaceable></arg></cmdsynopsis></term>
<listitem>
<para>
Stops the Erlang node on which RabbitMQ is running. To
@@ -111,6 +111,12 @@
the Server</citetitle> in the <ulink url="http://www.rabbitmq.com/install.html">installation
guide</ulink>.
</para>
+ <para>
+ If a <option>pid_file</option> is specified, also waits
+ for the process specified there to terminate. See the
+ description of the <option>wait</option> command below
+ for details on this file.
+ </para>
<para role="example-prefix">For example:</para>
<screen role="example">rabbitmqctl stop</screen>
<para role="example">
diff --git a/packaging/common/rabbitmq-server.init b/packaging/common/rabbitmq-server.init
index 15fd5d5b..450cac15 100644
--- a/packaging/common/rabbitmq-server.init
+++ b/packaging/common/rabbitmq-server.init
@@ -81,7 +81,7 @@ stop_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
set +e
- $CONTROL stop > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
+ $CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
RETVAL=$?
set -e
if [ $RETVAL = 0 ] ; then
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index 905e4fd0..cef5fd67 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -161,6 +161,10 @@ usage() ->
%%----------------------------------------------------------------------------
+action(stop, Node, [PidFile], _Opts, Inform) ->
+ action(stop, Node, [], _Opts, Inform),
+ wait_for_process_death(PidFile);
+
action(stop, Node, [], _Opts, Inform) ->
Inform("Stopping and halting node ~p", [Node]),
call(Node, {rabbit, stop_and_halt, []});
@@ -376,6 +380,20 @@ wait_for_application(Node, Pid) ->
false -> {error, process_not_running}
end.
+wait_for_process_death(PidFile) ->
+ Pid = case file:read_file(PidFile) of
+ {ok, Bin} -> string:strip(binary_to_list(Bin), right, $\n);
+ {error, _} = E -> exit({error, {could_not_read_pid, E}})
+ end,
+ wait_for_process_death1(Pid).
+
+wait_for_process_death1(Pid) ->
+ case process_up(Pid) of
+ true -> timer:sleep(1000),
+ wait_for_process_death1(Pid);
+ false -> ok
+ end.
+
wait_and_read_pid_file(PidFile) ->
case file:read_file(PidFile) of
{ok, Bin} -> string:strip(binary_to_list(Bin), right, $\n);