rabbit_env: Rename `data_dir` to `home_dir`
This value is used internally by `rabbit_env` and usually not read by RabbitMQ otherwise. This patch prepares the rename of `mnesia_dir` to `data_dir`, in order to not semantically rely on Mnesia configuration or use to locate data, whether it is stored in Mnesia or not.
This commit is contained in:
parent
7304d6cde2
commit
e0b4bce4f4
|
|
@ -118,7 +118,7 @@ get_context_after_logging_init(Context) ->
|
|||
Steps = [
|
||||
fun sys_prefix/1,
|
||||
fun rabbitmq_base/1,
|
||||
fun data_dir/1,
|
||||
fun home_dir/1,
|
||||
fun rabbitmq_home/1,
|
||||
fun config_base_dir/1,
|
||||
fun load_conf_env_file/1,
|
||||
|
|
@ -813,12 +813,12 @@ mnesia_base_dir_from_node(Context) ->
|
|||
%% variables based on it are relevant.
|
||||
update_context(Context, mnesia_base_dir, undefined, default).
|
||||
|
||||
get_default_mnesia_base_dir(#{data_dir := DataDir} = Context) ->
|
||||
get_default_mnesia_base_dir(#{home_dir := HomeDir} = Context) ->
|
||||
Basename = case Context of
|
||||
#{os_type := {unix, _}} -> "mnesia";
|
||||
#{os_type := {win32, _}} -> "db"
|
||||
end,
|
||||
normalize_path(DataDir, Basename).
|
||||
normalize_path(HomeDir, Basename).
|
||||
|
||||
mnesia_dir(#{from_remote_node := Remote} = Context) ->
|
||||
case get_prefixed_env_var("RABBITMQ_MNESIA_DIR") of
|
||||
|
|
@ -1270,13 +1270,13 @@ rabbitmq_base(#{os_type := {win32, _}} = Context) ->
|
|||
rabbitmq_base(Context) ->
|
||||
Context.
|
||||
|
||||
data_dir(#{os_type := {unix, _},
|
||||
home_dir(#{os_type := {unix, _},
|
||||
sys_prefix := SysPrefix} = Context) ->
|
||||
Dir = normalize_path(SysPrefix, "var", "lib", "rabbitmq"),
|
||||
update_context(Context, data_dir, Dir);
|
||||
data_dir(#{os_type := {win32, _},
|
||||
update_context(Context, home_dir, Dir);
|
||||
home_dir(#{os_type := {win32, _},
|
||||
rabbitmq_base := RabbitmqBase} = Context) ->
|
||||
update_context(Context, data_dir, RabbitmqBase).
|
||||
update_context(Context, home_dir, RabbitmqBase).
|
||||
|
||||
rabbitmq_home(Context) ->
|
||||
case get_env_var("RABBITMQ_HOME") of
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
end_per_group/2,
|
||||
init_per_testcase/2,
|
||||
end_per_testcase/2,
|
||||
check_data_dir/1,
|
||||
check_home_dir/1,
|
||||
check_default_values/1,
|
||||
check_values_from_reachable_remote_node/1,
|
||||
check_values_from_offline_remote_node/1,
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
all() ->
|
||||
[
|
||||
check_data_dir,
|
||||
check_home_dir,
|
||||
check_default_values,
|
||||
check_values_from_reachable_remote_node,
|
||||
check_values_from_offline_remote_node,
|
||||
|
|
@ -126,7 +126,7 @@ end_per_group(_, Config) -> Config.
|
|||
init_per_testcase(_, Config) -> Config.
|
||||
end_per_testcase(_, Config) -> Config.
|
||||
|
||||
check_data_dir(_) ->
|
||||
check_home_dir(_) ->
|
||||
{Variable, ExpValue} = case os:type() of
|
||||
{win32, _} ->
|
||||
{"RABBITMQ_BASE",
|
||||
|
|
@ -137,11 +137,11 @@ check_data_dir(_) ->
|
|||
end,
|
||||
Value = "value of " ++ Variable,
|
||||
os:putenv(Variable, Value),
|
||||
?assertMatch(#{data_dir := ExpValue}, rabbit_env:get_context()),
|
||||
?assertMatch(#{home_dir := ExpValue}, rabbit_env:get_context()),
|
||||
|
||||
os:unsetenv(Variable),
|
||||
?assertNotMatch(#{data_dir := ExpValue}, rabbit_env:get_context()),
|
||||
?assertMatch(#{data_dir := _}, rabbit_env:get_context()),
|
||||
?assertNotMatch(#{home_dir := ExpValue}, rabbit_env:get_context()),
|
||||
?assertMatch(#{home_dir := _}, rabbit_env:get_context()),
|
||||
|
||||
os:unsetenv(Variable).
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ check_default_values(_) ->
|
|||
amqp_tcp_port => 5672,
|
||||
conf_env_file => "/etc/rabbitmq/rabbitmq-env.conf",
|
||||
config_base_dir => "/etc/rabbitmq",
|
||||
data_dir => "/var/lib/rabbitmq",
|
||||
home_dir => "/var/lib/rabbitmq",
|
||||
dbg_mods => [],
|
||||
dbg_output => stdout,
|
||||
default_user => undefined,
|
||||
|
|
@ -264,7 +264,7 @@ check_default_values(_) ->
|
|||
amqp_tcp_port => 5672,
|
||||
conf_env_file => "%APPDATA%/RabbitMQ/rabbitmq-env-conf.bat",
|
||||
config_base_dir => "%APPDATA%/RabbitMQ",
|
||||
data_dir => "%APPDATA%/RabbitMQ",
|
||||
home_dir => "%APPDATA%/RabbitMQ",
|
||||
dbg_mods => [],
|
||||
dbg_output => stdout,
|
||||
default_user => undefined,
|
||||
|
|
@ -433,7 +433,7 @@ check_values_from_reachable_remote_node(Config) ->
|
|||
amqp_tcp_port => 5672,
|
||||
conf_env_file => "/etc/rabbitmq/rabbitmq-env.conf",
|
||||
config_base_dir => "/etc/rabbitmq",
|
||||
data_dir => "/var/lib/rabbitmq",
|
||||
home_dir => "/var/lib/rabbitmq",
|
||||
dbg_mods => [],
|
||||
dbg_output => stdout,
|
||||
default_user => undefined,
|
||||
|
|
@ -555,7 +555,7 @@ check_values_from_offline_remote_node(_) ->
|
|||
amqp_tcp_port => 5672,
|
||||
conf_env_file => "/etc/rabbitmq/rabbitmq-env.conf",
|
||||
config_base_dir => "/etc/rabbitmq",
|
||||
data_dir => "/var/lib/rabbitmq",
|
||||
home_dir => "/var/lib/rabbitmq",
|
||||
dbg_mods => [],
|
||||
dbg_output => stdout,
|
||||
default_user => undefined,
|
||||
|
|
|
|||
Loading…
Reference in New Issue