diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-04-20 19:07:06 +0200 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-04-21 09:51:43 +0200 |
| commit | d12654a320ffd80a394ad4fac6720231bfadabc9 (patch) | |
| tree | dc68f8914a0562089963241f1389e933882223d9 | |
| parent | 50597aa117bf2017fa4a66b2de67feda3f5d7c41 (diff) | |
| download | rabbitmq-server-git-d12654a320ffd80a394ad4fac6720231bfadabc9.tar.gz | |
rabbitmq-env: Check the Mnesia directory is not used for other purposes
If this is the case, log a warning to stderr.
Here is an example with the plugins expansion directory:
WARNING: RABBITMQ_PLUGINS_EXPAND_DIR is located inside RABBITMQ_MNESIA_DIR
=> Auto-clustering will not work ('cluster_nodes' in rabbitmq.config)
And with the log directory:
WARNING: RABBITMQ_LOG_BASE is equal to RABBITMQ_MNESIA_DIR
RABBITMQ_LOGS is located inside RABBITMQ_MNESIA_DIR
RABBITMQ_SASL_LOGS is located inside RABBITMQ_MNESIA_DIR
=> Auto-clustering will not work ('cluster_nodes' in rabbitmq.config)
Fixes #120.
| -rwxr-xr-x | scripts/rabbitmq-env | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/rabbitmq-env b/scripts/rabbitmq-env index 8a1b4d6510..42c69e07e0 100755 --- a/scripts/rabbitmq-env +++ b/scripts/rabbitmq-env @@ -70,6 +70,48 @@ fi ##--- Set environment vars RABBITMQ_<var_name> to defaults if not set +rmq_realpath() { + local path=$1 + + if [ -d "$path" ]; then + cd "$dir" && pwd + elif [ -f "$path" ]; then + cd "$(dirname "$dir")" && echo $(pwd)/$(basename "$path") + else + echo "$path" + fi +} + +rmq_check_if_shared_with_mnesia() { + local var + + local mnesia_dir=$(rmq_realpath "${RABBITMQ_MNESIA_DIR}") + local prefix="WARNING:" + + for var in "$@"; do + local dir=$(eval "echo \"\$$var\"") + + case $(rmq_realpath "$dir") in + ${mnesia_dir}) + warning=1 + echo "$prefix $var is equal to RABBITMQ_MNESIA_DIR" 1>&2 + ;; + ${mnesia_dir}/*) + warning=1 + echo "$prefix $var is located inside RABBITMQ_MNESIA_DIR" 1>&2 + ;; + esac + + if [ "x$warning" = "x1" ]; then + prefix=" " + fi + done + + if [ "x$warning" = "x1" ]; then + echo "$prefix => Auto-clustering will not work ('cluster_nodes' in rabbitmq.config)" 1>&2 + fi +} + DEFAULT_NODE_IP_ADDRESS=auto DEFAULT_NODE_PORT=5672 [ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS} @@ -110,6 +152,21 @@ DEFAULT_NODE_PORT=5672 [ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS=${CTL_ERL_ARGS} +# Check if files and directories non-related to Mnesia are configured +# to be in $RABBITMQ_MNESIA_DIR. If this is the case, issue a warning +# because it will prevent auto-clustering from working (the node will be +# considered non-virgin). + +rmq_check_if_shared_with_mnesia \ + RABBITMQ_CONFIG_FILE \ + RABBITMQ_LOG_BASE \ + RABBITMQ_PID_FILE \ + RABBITMQ_PLUGINS_EXPAND_DIR \ + RABBITMQ_ENABLED_PLUGINS_FILE \ + RABBITMQ_PLUGINS_DIR \ + RABBITMQ_LOGS \ + RABBITMQ_SASL_LOGS + ##--- End of overridden <var_name> variables # Since we source this elsewhere, don't accidentally stop execution |
