diff options
| author | Emile Joubert <emile@rabbitmq.com> | 2010-12-07 12:29:59 +0000 |
|---|---|---|
| committer | Emile Joubert <emile@rabbitmq.com> | 2010-12-07 12:29:59 +0000 |
| commit | 1c60674660cb83ff8a8b9cbab61ea072309626da (patch) | |
| tree | 57fbf3613ae04bd95182adea48a1b63f1db0f6cf /src | |
| parent | 1f08aaca050344ed49f344495c0cfd007d10cd8c (diff) | |
| download | rabbitmq-server-git-1c60674660cb83ff8a8b9cbab61ea072309626da.tar.gz | |
Cope with absence of epmd while performing pre-launch checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_prelaunch.erl | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl index 35cc79d4c8..796343522c 100644 --- a/src/rabbit_prelaunch.erl +++ b/src/rabbit_prelaunch.erl @@ -53,7 +53,7 @@ start() -> io:format("Activating RabbitMQ plugins ...~n"), %% Determine our various directories - [PluginDir, UnpackedPluginDir, NodeName] = init:get_plain_arguments(), + [PluginDir, UnpackedPluginDir, Node] = init:get_plain_arguments(), RootName = UnpackedPluginDir ++ "/rabbit", %% Unpack any .ez plugins @@ -132,19 +132,28 @@ start() -> || App <- PluginApps], io:nl(), - % check whether it is possible to start a node with the requested nodename - case net_kernel:start([list_to_atom(NodeName), shortnames]) of - {ok, _Pid} -> ok = net_kernel:stop(); - {error, Result} -> - % consistent layout by flushing error_log mailbox - gen_event:which_handlers(error_logger), - io:format("starting node with name ~p failed. " - "(is RabbitMQ already running?)~n~p~n", - [NodeName, Result]), - [io:format(Fmt ++ "~n", Args) || - {Fmt, Args} <- rabbit_control:diagnostics(NodeName)], - terminate(?ERROR_CODE) + % check whether a node with the same name is already running + case Node of + [] -> ok; + _ -> {NodeName, NodeHost} = rabbit_misc:nodeparts(Node), + case net_adm:names(NodeHost) of + {ok, NamePorts} -> + case proplists:is_defined(NodeName, NamePorts) of + true -> io:format("node with name ~p " + "already running on ~p~n", + [NodeName, NodeHost]), + [io:format(Fmt ++ "~n", Args) || + {Fmt, Args} <- + rabbit_control:diagnostics(Node)], + terminate(?ERROR_CODE); + false -> ok + end; + {error, address} -> ok; + {error, EpmdReason} -> terminate("unexpected epmd error:~p~n", + [EpmdReason]) + end end, + terminate(0), ok. |
