diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-10-25 15:45:13 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-10-25 15:45:13 +0100 |
| commit | e47f91aa09663cd5969c824cca78fe03c5001589 (patch) | |
| tree | cbfd119a6701ec88beea6a5b6cf5f2c16dd49446 /src | |
| parent | 4e6377cc7d56d92f3f5721308591ba3c3872fb18 (diff) | |
| download | rabbitmq-server-git-e47f91aa09663cd5969c824cca78fe03c5001589.tar.gz | |
rebase on default
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_control.erl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index 905e4fd062..cef5fd6732 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); |
