summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-06-05 11:42:06 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-06-05 11:42:06 +0100
commit9069d90a0656aeaa88de4d8dd3da30077a692098 (patch)
tree87f31a5d5850e76b99a5b340bc6ebca6148e6fd8
parentcd3164ef9fcba81a1ea6be4db221e5f1ddfbcb82 (diff)
parent6465e45484578dccf83649b6f5745df1bc70f733 (diff)
downloadrabbitmq-server-9069d90a0656aeaa88de4d8dd3da30077a692098.tar.gz
Merge bug26227
-rwxr-xr-xscripts/rabbitmq-service.bat1
-rw-r--r--src/rabbit.erl22
2 files changed, 20 insertions, 3 deletions
diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat
index 70402097..895561d4 100755
--- a/scripts/rabbitmq-service.bat
+++ b/scripts/rabbitmq-service.bat
@@ -229,6 +229,7 @@ set ERLANG_SERVICE_ARGUMENTS= ^
-rabbit enabled_plugins_file \""!RABBITMQ_ENABLED_PLUGINS_FILE:\=/!"\" ^
-rabbit plugins_dir \""!RABBITMQ_PLUGINS_DIR:\=/!"\" ^
-rabbit plugins_expand_dir \""!RABBITMQ_PLUGINS_EXPAND_DIR:\=/!"\" ^
+-rabbit windows_service_config \""!RABBITMQ_CONFIG_FILE:\=/!"\" ^
-os_mon start_cpu_sup false ^
-os_mon start_disksup false ^
-os_mon start_memsup false ^
diff --git a/src/rabbit.erl b/src/rabbit.erl
index c2d7e29d..29e38c1f 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -794,9 +794,25 @@ config_files() ->
end,
case init:get_argument(config) of
{ok, Files} -> [Abs(File) || [File] <- Files];
- error -> case os:getenv("RABBITMQ_CONFIG_FILE") of
- false -> [];
- File -> [Abs(File) ++ " (not found)"]
+ error -> case config_setting() of
+ none -> [];
+ File -> [Abs(File) ++ " (not found)"]
+ end
+ end.
+
+%% This is a pain. We want to know where the config file is. But we
+%% can't specify it on the command line if it is missing or the VM
+%% will fail to start, so we need to find it by some mechanism other
+%% than init:get_arguments/0. We can look at the environment variable
+%% which is responsible for setting it... but that doesn't work for a
+%% Windows service since the variable can change and the service not
+%% be reinstalled, so in that case we add a magic application env.
+config_setting() ->
+ case application:get_env(rabbit, windows_service_config) of
+ {ok, File1} -> File1;
+ undefined -> case os:getenv("RABBITMQ_CONFIG_FILE") of
+ false -> none;
+ File2 -> File2
end
end.