diff options
author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2020-01-16 14:22:07 +0100 |
---|---|---|
committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2020-02-03 10:12:49 +0100 |
commit | 15b07b66ceba56509da843f73c8c9a151bd6d08c (patch) | |
tree | 1d330e03f3ee5ae1b8183a59f1c2bceb10debb48 /src | |
parent | 3be5483ec22feca1460e09aaf21b629c9c72ec3e (diff) | |
download | rabbitmq-server-git-15b07b66ceba56509da843f73c8c9a151bd6d08c.tar.gz |
Move all RabbitMQ-specific environment variables to `rabbit_env`
The reading of `$NOTIFY_SOCKET` is also moved at the same time. This is
in preparation of the work around start/stop status.
There is an associated commit in rabbitmq-common to update `rabbit_env`
and record the origin of each variable.
[#170149339]
Diffstat (limited to 'src')
-rw-r--r-- | src/rabbit.erl | 11 | ||||
-rw-r--r-- | src/rabbit_feature_flags.erl | 28 | ||||
-rw-r--r-- | src/rabbit_lager.erl | 12 | ||||
-rw-r--r-- | src/rabbit_nodes.erl | 6 |
4 files changed, 28 insertions, 29 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 0bf6d47700..41a54ba36c 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -386,10 +386,9 @@ maybe_sd_notify() -> end. sd_notify_ready() -> - case {os:type(), os:getenv("NOTIFY_SOCKET")} of - {{win32, _}, _} -> - true; - {_, [_|_]} -> %% Non-empty NOTIFY_SOCKET, give it a try + case rabbit_prelaunch:get_context() of + #{systemd_notify_socket := Socket} when Socket =/= undefined -> + %% Non-empty NOTIFY_SOCKET, give it a try sd_notify_legacy() orelse sd_notify_socat(); _ -> true @@ -432,9 +431,11 @@ socat_socket_arg(UnixSocket) -> "unix-sendto:" ++ UnixSocket. sd_open_port() -> + #{systemd_notify_socket := Socket} = rabbit_prelaunch:get_context(), + true = Socket =/= undefined, open_port( {spawn_executable, os:find_executable("socat")}, - [{args, [socat_socket_arg(os:getenv("NOTIFY_SOCKET")), "STDIO"]}, + [{args, [socat_socket_arg(Socket), "STDIO"]}, use_stdio, out]). sd_notify_socat(Unit) -> diff --git a/src/rabbit_feature_flags.erl b/src/rabbit_feature_flags.erl index 054bc90a0b..9be78eec13 100644 --- a/src/rabbit_feature_flags.erl +++ b/src/rabbit_feature_flags.erl @@ -1246,22 +1246,17 @@ regen_registry_mod(AllFeatureFlags, {error, {compilation_failure, Errors, Warnings}} end. --ifdef(TEST). maybe_log_registry_source_code(Forms) -> - case os:getenv("LOG_FF_REGISTRY") of - false -> - ok; - _ -> + case rabbit_prelaunch:get_context() of + #{log_feature_flags_registry := true} -> rabbit_log_feature_flags:debug( "== FEATURE FLAGS REGISTRY ==~n" "~s~n" "== END ==~n", - [erl_prettypr:format(erl_syntax:form_list(Forms))]) + [erl_prettypr:format(erl_syntax:form_list(Forms))]); + _ -> + ok end. --else. -maybe_log_registry_source_code(_) -> - ok. --endif. -spec load_registry_mod(atom(), binary()) -> ok | {error, any()} | no_return(). @@ -2003,7 +1998,7 @@ sync_feature_flags_with_cluster([], NodeIsVirgin, _) -> "Feature flags: starting an unclustered " "node for the first time: all feature " "flags are forcibly left disabled from " - "the RABBITMQ_FEATURE_FLAGS environment " + "the $RABBITMQ_FEATURE_FLAGS environment " "variable"), ok; _ -> @@ -2011,7 +2006,7 @@ sync_feature_flags_with_cluster([], NodeIsVirgin, _) -> "Feature flags: starting an unclustered " "node for the first time: only the " "following feature flags specified in " - "the RABBITMQ_FEATURE_FLAGS environment " + "the $RABBITMQ_FEATURE_FLAGS environment " "variable will be enabled: ~p", [FeatureNames]), enable(FeatureNames) @@ -2126,9 +2121,12 @@ get_forced_feature_flag_names() -> %% @private get_forced_feature_flag_names_from_env() -> - case os:getenv("RABBITMQ_FEATURE_FLAGS") of - false -> undefined; - Value -> [list_to_atom(V) ||V <- string:lexemes(Value, ",")] + case rabbit_prelaunch:get_context() of + #{forced_feature_flags_on_init := ForcedFFs} + when is_list(ForcedFFs) -> + ForcedFFs; + _ -> + undefined end. -spec get_forced_feature_flag_names_from_config() -> [feature_name()] | undefined. diff --git a/src/rabbit_lager.erl b/src/rabbit_lager.erl index e9dce91909..a5c591b1ce 100644 --- a/src/rabbit_lager.erl +++ b/src/rabbit_lager.erl @@ -299,7 +299,7 @@ configure_lager() -> end, LogLevelsFromContext = case rabbit_prelaunch:get_context() of #{log_levels := LL} -> LL; - undefined -> undefined + _ -> undefined end, Fun = fun (global, _, CC) -> @@ -473,12 +473,14 @@ prepare_rabbit_log_config() -> tty -> set_env_default_log_console(); FileName when is_list(FileName) -> - case os:getenv("RABBITMQ_LOGS_source") of + case rabbit_prelaunch:get_context() of %% The user explicitly sets $RABBITMQ_LOGS; %% we should override a file location even %% if it's set in rabbitmq.config - "environment" -> set_env_default_log_file(FileName, override); - _ -> set_env_default_log_file(FileName, keep) + #{var_origins := #{main_log_file := environment}} -> + set_env_default_log_file(FileName, override); + _ -> + set_env_default_log_file(FileName, keep) end end, @@ -551,7 +553,7 @@ set_env_upgrade_log_file(FileName) -> generate_lager_sinks(SinkNames, SinkConfigs) -> LogLevels = case rabbit_prelaunch:get_context() of #{log_levels := LL} -> LL; - undefined -> undefined + _ -> undefined end, DefaultLogLevel = case LogLevels of #{global := LogLevel} -> diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl index eb582c69f5..af0a546db5 100644 --- a/src/rabbit_nodes.erl +++ b/src/rabbit_nodes.erl @@ -41,10 +41,8 @@ boot() -> seed_user_provided_cluster_name(). name_type() -> - case os:getenv("RABBITMQ_USE_LONGNAME") of - "true" -> longnames; - _ -> shortnames - end. + #{nodename_type := NodeType} = rabbit_prelaunch:get_context(), + NodeType. -spec names(string()) -> rabbit_types:ok_or_error2([{string(), integer()}], term()). |