Skip to content

Commit f6361b5

Browse files
author
Simon MacMullen
committed
Merge bug26227
2 parents b159b4b + a3b0fab commit f6361b5

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

scripts/rabbitmq-service.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ set ERLANG_SERVICE_ARGUMENTS= ^
229229
-rabbit enabled_plugins_file \""!RABBITMQ_ENABLED_PLUGINS_FILE:\=/!"\" ^
230230
-rabbit plugins_dir \""!RABBITMQ_PLUGINS_DIR:\=/!"\" ^
231231
-rabbit plugins_expand_dir \""!RABBITMQ_PLUGINS_EXPAND_DIR:\=/!"\" ^
232+
-rabbit windows_service_config \""!RABBITMQ_CONFIG_FILE:\=/!"\" ^
232233
-os_mon start_cpu_sup false ^
233234
-os_mon start_disksup false ^
234235
-os_mon start_memsup false ^

src/rabbit.erl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,25 @@ config_files() ->
794794
end,
795795
case init:get_argument(config) of
796796
{ok, Files} -> [Abs(File) || [File] <- Files];
797-
error -> case os:getenv("RABBITMQ_CONFIG_FILE") of
798-
false -> [];
799-
File -> [Abs(File) ++ " (not found)"]
797+
error -> case config_setting() of
798+
none -> [];
799+
File -> [Abs(File) ++ " (not found)"]
800+
end
801+
end.
802+
803+
%% This is a pain. We want to know where the config file is. But we
804+
%% can't specify it on the command line if it is missing or the VM
805+
%% will fail to start, so we need to find it by some mechanism other
806+
%% than init:get_arguments/0. We can look at the environment variable
807+
%% which is responsible for setting it... but that doesn't work for a
808+
%% Windows service since the variable can change and the service not
809+
%% be reinstalled, so in that case we add a magic application env.
810+
config_setting() ->
811+
case application:get_env(rabbit, windows_service_config) of
812+
{ok, File1} -> File1;
813+
undefined -> case os:getenv("RABBITMQ_CONFIG_FILE") of
814+
false -> none;
815+
File2 -> File2
800816
end
801817
end.
802818

0 commit comments

Comments
 (0)