diff options
author | Michael Klishin <michael@clojurewerkz.org> | 2019-08-12 21:55:15 +1000 |
---|---|---|
committer | Michael Klishin <michael@clojurewerkz.org> | 2019-08-12 21:55:15 +1000 |
commit | 1aba6fa06b040ea888c37be123d003bcd3af15f0 (patch) | |
tree | aedbf265ab6dd0348f8ed2133bf57978d8a7f873 | |
parent | d6e7c3841c5f01933e9182da1701bd2ac74eb1ff (diff) | |
download | rabbitmq-server-git-1aba6fa06b040ea888c37be123d003bcd3af15f0.tar.gz |
Make it possible to pre-configure cluster name via config
Per discussion with @gerhard.
-rw-r--r-- | priv/schema/rabbit.schema | 8 | ||||
-rw-r--r-- | src/rabbit.erl | 6 | ||||
-rw-r--r-- | src/rabbit_nodes.erl | 21 |
3 files changed, 31 insertions, 4 deletions
diff --git a/priv/schema/rabbit.schema b/priv/schema/rabbit.schema index 44c199ff4d..8c951cbecb 100644 --- a/priv/schema/rabbit.schema +++ b/priv/schema/rabbit.schema @@ -383,7 +383,7 @@ end}. {datatype, {enum, [distinguished_name, common_name]}} ]}. -%% SSL handshake timeout, in milliseconds. +%% TLS handshake timeout, in milliseconds. %% %% {ssl_handshake_timeout, 5000}, @@ -391,6 +391,12 @@ end}. {datatype, integer} ]}. +%% Cluster name + +{mapping, "cluster_name", "rabbit.cluster_name", [ + {datatype, string} +]}. + %% Default worker process pool size. Used to limit maximum concurrency rate %% of certain operations, e.g. queue initialisation and recovery on node boot. diff --git a/src/rabbit.erl b/src/rabbit.erl index fdf2138515..3dd963b813 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -226,6 +226,12 @@ [{description, "ready to communicate with peers and clients"}, {requires, [core_initialized, recovery, routing_ready]}]}). +-rabbit_boot_step({cluster_name, + [{description, "sets cluster name if configured"}, + {mfa, {rabbit_nodes, boot, []}}, + {requires, pre_flight} + ]}). + -rabbit_boot_step({direct_client, [{description, "direct client"}, {mfa, {rabbit_direct, boot, []}}, diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl index bfe5f271fd..2167610fcc 100644 --- a/src/rabbit_nodes.erl +++ b/src/rabbit_nodes.erl @@ -19,18 +19,28 @@ -export([names/1, diagnostics/1, make/1, parts/1, cookie_hash/0, is_running/2, is_process_running/2, - cluster_name/0, set_cluster_name/2, ensure_epmd/0, + cluster_name/0, set_cluster_name/1, set_cluster_name/2, ensure_epmd/0, all_running/0, name_type/0, running_count/0, - await_running_count/2]). + await_running_count/2, + boot/0]). -include_lib("kernel/include/inet.hrl"). +-include_lib("rabbit_common/include/rabbit.hrl"). -define(SAMPLING_INTERVAL, 1000). %%---------------------------------------------------------------------------- -%% Specs +%% API %%---------------------------------------------------------------------------- +boot() -> + case application:get_env(rabbit, cluster_name) of + undefined -> ok; + {ok, Name} -> + rabbit_log:info("Setting cluster name to '~s' as configured", [Name]), + set_cluster_name(rabbit_data_coercion:to_binary(Name)) + end. + name_type() -> case os:getenv("RABBITMQ_USE_LONGNAME") of "true" -> longnames; @@ -80,6 +90,11 @@ cluster_name_default() -> FQDN = rabbit_net:hostname(), list_to_binary(atom_to_list(make({ID, FQDN}))). +-spec set_cluster_name(binary()) -> 'ok'. + +set_cluster_name(Name) -> + set_cluster_name(Name, ?INTERNAL_USER). + -spec set_cluster_name(binary(), rabbit_types:username()) -> 'ok'. set_cluster_name(Name, Username) -> |