From 6465e45484578dccf83649b6f5745df1bc70f733 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 5 Jun 2014 11:41:51 +0100 Subject: Don't show misleading information in the Windows service case when the service has not been reinstalled. --- scripts/rabbitmq-service.bat | 1 + src/rabbit.erl | 22 +++++++++++++++++++--- 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. -- cgit v1.2.1