Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' into rabbitmq-cli-180
Conflicts:
	lib/rabbitmq/cli/core/distribution.ex
  • Loading branch information
michaelklishin committed Apr 5, 2017
commit 4ac1697bddb92213246cd65a3ddda958b7d71aba
25 changes: 18 additions & 7 deletions lib/rabbitmq/cli/core/distribution.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,35 @@ defmodule RabbitMQ.CLI.Core.Distribution do

def start(options) do
node_name_type = Config.get_option(:longnames, options)
:rabbit_nodes.ensure_epmd()
result = start(node_name_type, 10, :undefined)
ensure_cookie(options)
result
end

def start_as(node_name, options) do
:rabbit_nodes.ensure_epmd()
node_name_type = Config.get_option(:longnames, options)
result = :net_kernel.start([node_name, node_name_type])
result = start_with_epmd(node_name, node_name_type)
ensure_cookie(options)
result
end

## Optimization. We try to start EPMD only if distribution fails
def start_with_epmd(node_name, node_name_type) do
case :net_kernel.start([node_name, node_name_type]) do
{:ok, _} = ok -> ok;
{:error, {:already_started, _}} = started -> started;
{:error, {{:already_started, _}, _}} = started -> started;
## EPMD can be stopped. Retry with EPMD
{:error, _} ->
:rabbit_nodes.ensure_epmd()
:net_kernel.start([node_name, node_name_type])
end
end

#
# Implementation
#

def ensure_cookie(options) do
case Config.get_option(:erlang_cookie, options) do
nil -> :ok;
Expand All @@ -48,10 +63,6 @@ defmodule RabbitMQ.CLI.Core.Distribution do
end
end

#
# Implementation
#

defp start(_opt, 0, last_err) do
{:error, last_err}
end
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.