diff options
Diffstat (limited to 'deps/rabbit/scripts')
21 files changed, 1522 insertions, 0 deletions
diff --git a/deps/rabbit/scripts/rabbitmq-defaults b/deps/rabbit/scripts/rabbitmq-defaults new file mode 100755 index 0000000000..41d72c7da4 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-defaults @@ -0,0 +1,18 @@ +#!/bin/sh -e +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2012-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +### next line potentially updated in package install steps +SYS_PREFIX= + +CLEAN_BOOT_FILE=start_clean +SASL_BOOT_FILE=start_sasl +BOOT_MODULE="rabbit" + +if test -z "$CONF_ENV_FILE" && test -z "$RABBITMQ_CONF_ENV_FILE"; then + CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf +fi diff --git a/deps/rabbit/scripts/rabbitmq-defaults.bat b/deps/rabbit/scripts/rabbitmq-defaults.bat new file mode 100644 index 0000000000..41b3d2b47c --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-defaults.bat @@ -0,0 +1,21 @@ +@echo off
+
+set SASL_BOOT_FILE=start_sasl
+set CLEAN_BOOT_FILE=start_clean
+set BOOT_MODULE=rabbit
+
+if "!RABBITMQ_BASE!"=="" (
+ set RABBITMQ_BASE=!APPDATA!\RabbitMQ
+) else (
+ set RABBITMQ_BASE=!RABBITMQ_BASE:"=!
+)
+
+if not exist "!RABBITMQ_BASE!" (
+ mkdir "!RABBITMQ_BASE!"
+)
+
+if "!RABBITMQ_CONF_ENV_FILE!"=="" (
+ if "!CONF_ENV_FILE!"=="" (
+ set CONF_ENV_FILE=!RABBITMQ_BASE!\rabbitmq-env-conf.bat
+ )
+)
diff --git a/deps/rabbit/scripts/rabbitmq-diagnostics b/deps/rabbit/scripts/rabbitmq-diagnostics new file mode 100755 index 0000000000..7101f3cc9b --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-diagnostics @@ -0,0 +1,23 @@ +#!/bin/sh +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +# Exit immediately if a pipeline, which may consist of a single simple command, +# a list, or a compound command returns a non-zero status +set -e + +# Each variable or function that is created or modified is given the export +# attribute and marked for export to the environment of subsequent commands. +set -a + +# shellcheck source=/dev/null +# +# TODO: when shellcheck adds support for relative paths, change to +# shellcheck source=./rabbitmq-env +. "${0%/*}"/rabbitmq-env + +run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmq-diagnostics "$@" diff --git a/deps/rabbit/scripts/rabbitmq-diagnostics.bat b/deps/rabbit/scripts/rabbitmq-diagnostics.bat new file mode 100644 index 0000000000..af2982559c --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-diagnostics.bat @@ -0,0 +1,55 @@ +@echo off
+REM This Source Code Form is subject to the terms of the Mozilla Public
+REM License, v. 2.0. If a copy of the MPL was not distributed with this
+REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
+REM
+REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
+REM
+
+REM Scopes the variables to the current batch file
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+set STAR=%*
+setlocal enabledelayedexpansion
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B 1
+)
+
+REM Disable erl_crash.dump by default for control scripts.
+if not defined ERL_CRASH_DUMP_SECONDS (
+ set ERL_CRASH_DUMP_SECONDS=0
+)
+
+"!ERLANG_HOME!\bin\erl.exe" +B ^
+-boot !CLEAN_BOOT_FILE! ^
+-noinput -noshell -hidden -smp enable ^
+!RABBITMQ_CTL_ERL_ARGS! ^
+-kernel inet_dist_listen_min !RABBITMQ_CTL_DIST_PORT_MIN! ^
+-kernel inet_dist_listen_max !RABBITMQ_CTL_DIST_PORT_MAX! ^
+-run escript start ^
+-escript main rabbitmqctl_escript ^
+-extra "%RABBITMQ_HOME%\escript\rabbitmq-diagnostics" !STAR!
+
+if ERRORLEVEL 1 (
+ exit /B %ERRORLEVEL%
+)
+
+EXIT /B 0
+
+endlocal
diff --git a/deps/rabbit/scripts/rabbitmq-echopid.bat b/deps/rabbit/scripts/rabbitmq-echopid.bat new file mode 100644 index 0000000000..98080afd1f --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-echopid.bat @@ -0,0 +1,57 @@ +@echo off
+
+REM Usage: rabbitmq-echopid.bat <rabbitmq_nodename>
+REM
+REM <rabbitmq_nodename> (s)name of the erlang node to connect to (required)
+
+setlocal
+
+set TDP0=%~dp0
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+if "%1"=="" goto argfail
+
+:: set timeout vars ::
+set TIMEOUT=10
+set TIMER=1
+
+:: check that wmic exists ::
+set WMIC_PATH=%SYSTEMROOT%\System32\Wbem\wmic.exe
+if not exist "%WMIC_PATH%" (
+ goto fail
+)
+
+:getpid
+for /f "usebackq tokens=* skip=1" %%P IN (`%%WMIC_PATH%% process where "name='erl.exe' and commandline like '%%%RABBITMQ_NAME_TYPE% %1%%'" get processid 2^>nul`) do (
+ set PID=%%P
+ goto echopid
+)
+
+:echopid
+:: check for pid not found ::
+if "%PID%" == "" (
+ PING 127.0.0.1 -n 2 > nul
+ set /a TIMER+=1
+ if %TIMEOUT%==%TIMER% goto fail
+ goto getpid
+)
+
+:: show pid ::
+echo %PID%
+
+:: all done ::
+:ok
+endlocal
+EXIT /B 0
+
+:: argument is required ::
+:argfail
+echo Please provide your RabbitMQ node name as the argument to this script.
+
+:: something went wrong ::
+:fail
+endlocal
+EXIT /B 1
diff --git a/deps/rabbit/scripts/rabbitmq-env b/deps/rabbit/scripts/rabbitmq-env new file mode 100755 index 0000000000..90702c43bb --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-env @@ -0,0 +1,190 @@ +#!/bin/sh -e +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +if [ "$RABBITMQ_ENV_LOADED" = 1 ]; then + return 0; +fi + +if [ -z "$RABBITMQ_SCRIPTS_DIR" ]; then + # We set +e here since since our test for "readlink -f" below needs to + # be able to fail. + set +e + # Determine where this script is really located (if this script is + # invoked from another script, this is the location of the caller) + SCRIPT_PATH="$0" + while [ -h "$SCRIPT_PATH" ] ; do + # Determine if readlink -f is supported at all. TODO clean this up. + FULL_PATH=`readlink -f $SCRIPT_PATH 2>/dev/null` + if [ "$?" != "0" ]; then + REL_PATH=`readlink $SCRIPT_PATH` + if expr "$REL_PATH" : '/.*' > /dev/null; then + SCRIPT_PATH="$REL_PATH" + else + SCRIPT_PATH="`dirname "$SCRIPT_PATH"`/$REL_PATH" + fi + else + SCRIPT_PATH=$FULL_PATH + fi + done + set -e + + RABBITMQ_SCRIPTS_DIR=`dirname $SCRIPT_PATH` +fi + +_rmq_env_now() +{ + date '+%Y-%m-%d %H:%M:%S' +} + +_rmq_env_print() +{ + _rmq_env_tmp="$1" + _rmq_env_tmp_len="${#_rmq_env_tmp}" + shift + printf '%s %s %s\n' "$(_rmq_env_now)" "$_rmq_env_tmp" "$1" 1>&2 + shift + _rmq_env_print_line='' + _rmq_env_indent="$((_rmq_env_tmp_len + 21))" + for _rmq_env_print_line in "$@" + do + printf "%${_rmq_env_indent}s%s\n" ' ' "$_rmq_env_print_line" 1>&2 + done + unset _rmq_env_print_line + unset _rmq_env_indent + unset _rmq_env_tmp_len + unset _rmq_env_tmp +} + +_rmq_env_perr() +{ + _rmq_env_print '[error]' "$@" +} + +_rmq_env_pwarn() +{ + _rmq_env_print '[warning]' "$@" +} + +rmq_realpath() { + local path=$1 + + if [ -d "$path" ]; then + cd "$path" && pwd + elif [ -f "$path" ]; then + cd "$(dirname "$path")" && echo $(pwd)/$(basename "$path") + else + echo "$path" + fi +} + +RABBITMQ_HOME="$(rmq_realpath "${RABBITMQ_SCRIPTS_DIR}/..")" +ESCRIPT_DIR="${RABBITMQ_HOME}/escript" + +## Set defaults +. ${RABBITMQ_SCRIPTS_DIR}/rabbitmq-defaults + +# We save the current value of $RABBITMQ_PID_FILE in case it was set by +# an init script. If $CONF_ENV_FILE overrides it again, we must ignore +# it and warn the user. +saved_RABBITMQ_PID_FILE="$RABBITMQ_PID_FILE" + +## Get configuration variables from the configure environment file +[ "x" = "x$RABBITMQ_CONF_ENV_FILE" ] && RABBITMQ_CONF_ENV_FILE=${CONF_ENV_FILE} +if [ -f "${RABBITMQ_CONF_ENV_FILE}" ]; then + CONF_ENV_FILE_PHASE=rabbitmq-env + . ${RABBITMQ_CONF_ENV_FILE} || true +fi + +[ -n "$ERL_EPMD_PORT" ] && export ERL_EPMD_PORT +[ -n "$ERL_EPMD_ADDRESS" ] && export ERL_EPMD_ADDRESS + +DEFAULT_SCHEDULER_BIND_TYPE="db" +[ -n "$SCHEDULER_BIND_TYPE" ] || SCHEDULER_BIND_TYPE="$DEFAULT_SCHEDULER_BIND_TYPE" +[ -n "$RABBITMQ_SCHEDULER_BIND_TYPE" ] || RABBITMQ_SCHEDULER_BIND_TYPE="$SCHEDULER_BIND_TYPE" + +DEFAULT_DISTRIBUTION_BUFFER_SIZE=128000 +[ -n "$DISTRIBUTION_BUFFER_SIZE" ] || DISTRIBUTION_BUFFER_SIZE="$DEFAULT_DISTRIBUTION_BUFFER_SIZE" +[ -n "$RABBITMQ_DISTRIBUTION_BUFFER_SIZE" ] || RABBITMQ_DISTRIBUTION_BUFFER_SIZE="$DISTRIBUTION_BUFFER_SIZE" + +DEFAULT_MAX_NUMBER_OF_PROCESSES=1048576 +[ -n "$MAX_NUMBER_OF_PROCESSES" ] || MAX_NUMBER_OF_PROCESSES="$DEFAULT_MAX_NUMBER_OF_PROCESSES" +[ -n "$RABBITMQ_MAX_NUMBER_OF_PROCESSES" ] || RABBITMQ_MAX_NUMBER_OF_PROCESSES="$MAX_NUMBER_OF_PROCESSES" + +DEFAULT_MAX_NUMBER_OF_ATOMS=5000000 +[ -n "$MAX_NUMBER_OF_ATOMS" ] || MAX_NUMBER_OF_ATOMS="$DEFAULT_MAX_NUMBER_OF_ATOMS" +[ -n "$RABBITMQ_MAX_NUMBER_OF_ATOMS" ] || RABBITMQ_MAX_NUMBER_OF_ATOMS="$MAX_NUMBER_OF_ATOMS" + +## Common server defaults +SERVER_ERL_ARGS=" +P $RABBITMQ_MAX_NUMBER_OF_PROCESSES +t $RABBITMQ_MAX_NUMBER_OF_ATOMS +stbt $RABBITMQ_SCHEDULER_BIND_TYPE +zdbbl $RABBITMQ_DISTRIBUTION_BUFFER_SIZE " + +##--- Set environment vars RABBITMQ_<var_name> to defaults if not set + +[ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS="$CTL_ERL_ARGS" +[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MIN" ] && RABBITMQ_CTL_DIST_PORT_MIN="$CTL_DIST_PORT_MIN" +[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MAX" ] && RABBITMQ_CTL_DIST_PORT_MAX="$CTL_DIST_PORT_MAX" +[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MIN" ] && RABBITMQ_CTL_DIST_PORT_MIN='35672' +[ "x" = "x$RABBITMQ_CTL_DIST_PORT_MAX" ] && RABBITMQ_CTL_DIST_PORT_MAX="$(($RABBITMQ_CTL_DIST_PORT_MIN + 10))" + +[ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS} +[ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS=${SERVER_START_ARGS} +[ "x" = "x$RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS" ] && RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=${SERVER_ADDITIONAL_ERL_ARGS} +[ "x" = "x$RABBITMQ_SERVER_CODE_PATH" ] && RABBITMQ_SERVER_CODE_PATH=${SERVER_CODE_PATH} +[ "x" = "x$RABBITMQ_IGNORE_SIGINT" ] && RABBITMQ_IGNORE_SIGINT="true" +[ "xtrue" = "x$RABBITMQ_IGNORE_SIGINT" ] && RABBITMQ_IGNORE_SIGINT_FLAG="+B i" + +if [ -n "$saved_RABBITMQ_PID_FILE" ] && \ + [ "$saved_RABBITMQ_PID_FILE" != "$RABBITMQ_PID_FILE" ] +then + _rmq_env_pwarn 'RABBITMQ_PID_FILE was already set by the init script to:' \ + "$saved_RABBITMQ_PID_FILE" \ + 'The value set in rabbitmq-env.conf is ignored because it would break the init script.' + + RABBITMQ_PID_FILE="$saved_RABBITMQ_PID_FILE" +fi + +[ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE} + +##--- End of overridden <var_name> variables + +_rmq_env_set_erl_libs() +{ + if [ -n "$ERL_LIBS" ] + then + export ERL_LIBS="$RABBITMQ_HOME/plugins:$ERL_LIBS" + else + export ERL_LIBS="$RABBITMQ_HOME/plugins" + fi +} + +run_escript() +{ + escript_main="${1:?escript_main must be defined}" + shift + escript="${1:?escript must be defined}" + shift + + _rmq_env_set_erl_libs + + # Important: do not quote RABBITMQ_CTL_ERL_ARGS as they must be + # word-split + # shellcheck disable=SC2086 + exec erl +B \ + -boot "$CLEAN_BOOT_FILE" \ + -noinput -noshell -hidden -smp enable \ + $RABBITMQ_CTL_ERL_ARGS \ + -kernel inet_dist_listen_min "$RABBITMQ_CTL_DIST_PORT_MIN" \ + -kernel inet_dist_listen_max "$RABBITMQ_CTL_DIST_PORT_MAX" \ + -run escript start \ + -escript main "$escript_main" \ + -extra "$escript" "$@" +} + +RABBITMQ_ENV_LOADED=1 + +# Since we source this elsewhere, don't accidentally stop execution +true diff --git a/deps/rabbit/scripts/rabbitmq-env.bat b/deps/rabbit/scripts/rabbitmq-env.bat new file mode 100644 index 0000000000..1db57b33c5 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-env.bat @@ -0,0 +1,173 @@ +@echo off
+
+REM Scopes the variables to the current batch file
+REM setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+REM setlocal enabledelayedexpansion
+
+REM SCRIPT_DIR=`dirname $SCRIPT_PATH`
+REM RABBITMQ_HOME="${SCRIPT_DIR}/.."
+set SCRIPT_DIR=%TDP0%
+set SCRIPT_NAME=%1
+for /f "delims=" %%F in ("%SCRIPT_DIR%..") do set RABBITMQ_HOME=%%~dpF%%~nF%%~xF
+
+if defined ERL_LIBS (
+ set "ERL_LIBS=%RABBITMQ_HOME%\plugins;%ERL_LIBS%"
+) else (
+ set "ERL_LIBS=%RABBITMQ_HOME%\plugins"
+)
+
+REM If ERLANG_HOME is not defined, check if "erl.exe" is available in
+REM the path and use that.
+if not defined ERLANG_HOME (
+ for /f "delims=" %%F in ('powershell.exe -NoLogo -NoProfile -NonInteractive -Command "(Get-Command erl.exe).Definition"') do @set ERL_PATH=%%F
+ if exist "!ERL_PATH!" (
+ for /f "delims=" %%F in ("!ERL_PATH!") do set ERL_DIRNAME=%%~dpF
+ for /f "delims=" %%F in ("!ERL_DIRNAME!\..") do @set ERLANG_HOME=%%~dpF%%~nF%%~xF
+ )
+ set ERL_PATH=
+ set ERL_DIRNAME=
+)
+
+REM ## Set defaults
+call "%SCRIPT_DIR%\rabbitmq-defaults.bat"
+
+if "!RABBITMQ_CONF_ENV_FILE!"=="" (
+ set RABBITMQ_CONF_ENV_FILE=!CONF_ENV_FILE:"=!
+) else (
+ set RABBITMQ_CONF_ENV_FILE=!RABBITMQ_CONF_ENV_FILE:"=!
+)
+
+if exist "!RABBITMQ_CONF_ENV_FILE!" (
+ call "!RABBITMQ_CONF_ENV_FILE!"
+)
+
+rem Bump ETS table limit to 50000
+if "!ERL_MAX_ETS_TABLES!"=="" (
+ set ERL_MAX_ETS_TABLES=50000
+)
+
+rem Default is defined here:
+rem https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_port.h
+if "!ERL_MAX_PORTS!"=="" (
+ set ERL_MAX_PORTS=65536
+)
+
+set DEFAULT_SCHEDULER_BIND_TYPE=db
+if "!RABBITMQ_SCHEDULER_BIND_TYPE!"=="" (
+ set RABBITMQ_SCHEDULER_BIND_TYPE=!SCHEDULER_BIND_TYPE!
+)
+if "!RABBITMQ_SCHEDULER_BIND_TYPE!"=="" (
+ set RABBITMQ_SCHEDULER_BIND_TYPE=!DEFAULT_SCHEDULER_BIND_TYPE!
+)
+
+set DEFAULT_DISTRIBUTION_BUFFER_SIZE=128000
+if "!RABBITMQ_DISTRIBUTION_BUFFER_SIZE!"=="" (
+ set RABBITMQ_DISTRIBUTION_BUFFER_SIZE=!DISTRIBUTION_BUFFER_SIZE!
+)
+if "!RABBITMQ_DISTRIBUTION_BUFFER_SIZE!"=="" (
+ set RABBITMQ_DISTRIBUTION_BUFFER_SIZE=!DEFAULT_DISTRIBUTION_BUFFER_SIZE!
+)
+
+set DEFAULT_MAX_NUMBER_OF_PROCESSES=1048576
+if "!RABBITMQ_MAX_NUMBER_OF_PROCESSES!"=="" (
+ set RABBITMQ_MAX_NUMBER_OF_PROCESSES=!MAX_NUMBER_OF_PROCESSES!
+)
+if "!RABBITMQ_MAX_NUMBER_OF_PROCESSES!"=="" (
+ set RABBITMQ_MAX_NUMBER_OF_PROCESSES=!DEFAULT_MAX_NUMBER_OF_PROCESSES!
+)
+
+set DEFAULT_MAX_NUMBER_OF_ATOMS=5000000
+if "!RABBITMQ_MAX_NUMBER_OF_ATOMS!"=="" (
+ set RABBITMQ_MAX_NUMBER_OF_ATOMS=!MAX_NUMBER_OF_ATOMS!
+)
+if "!RABBITMQ_MAX_NUMBER_OF_ATOMS!"=="" (
+ set RABBITMQ_MAX_NUMBER_OF_ATOMS=!DEFAULT_MAX_NUMBER_OF_ATOMS!
+)
+
+REM Common server defaults
+set SERVER_ERL_ARGS=+P !RABBITMQ_MAX_NUMBER_OF_PROCESSES! +t !RABBITMQ_MAX_NUMBER_OF_ATOMS! +stbt !RABBITMQ_SCHEDULER_BIND_TYPE! +zdbbl !RABBITMQ_DISTRIBUTION_BUFFER_SIZE!
+
+REM ##--- Set environment vars RABBITMQ_<var_name> to defaults if not set
+
+REM [ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_SERVER_ERL_ARGS=${SERVER_ERL_ARGS}
+if "!RABBITMQ_SERVER_ERL_ARGS!"=="" (
+ set RABBITMQ_SERVER_ERL_ARGS=!SERVER_ERL_ARGS!
+)
+
+REM [ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS=${SERVER_START_ARGS}
+if "!RABBITMQ_SERVER_START_ARGS!"=="" (
+ if not "!SERVER_START_ARGS!"=="" (
+ set RABBITMQ_SERVER_START_ARGS=!SERVER_START_ARGS!
+ )
+)
+
+REM [ "x" = "x$RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS" ] && RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=${SERVER_ADDITIONAL_ERL_ARGS}
+if "!RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS!"=="" (
+ if not "!SERVER_ADDITIONAL_ERL_ARGS!"=="" (
+ set RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=!SERVER_ADDITIONAL_ERL_ARGS!
+ )
+)
+
+REM [ "x" = "x$RABBITMQ_BOOT_MODULE" ] && RABBITMQ_BOOT_MODULE=${BOOT_MODULE}
+if "!RABBITMQ_BOOT_MODULE!"=="" (
+ if "!BOOT_MODULE!"=="" (
+ set RABBITMQ_BOOT_MODULE=rabbit
+ ) else (
+ set RABBITMQ_BOOT_MODULE=!BOOT_MODULE!
+ )
+)
+
+REM [ "x" = "x$RABBITMQ_CTL_ERL_ARGS" ] && RABBITMQ_CTL_ERL_ARGS=${CTL_ERL_ARGS}
+if "!RABBITMQ_CTL_ERL_ARGS!"=="" (
+ if not "!CTL_ERL_ARGS!"=="" (
+ set RABBITMQ_CTL_ERL_ARGS=!CTL_ERL_ARGS!
+ )
+)
+
+if "!RABBITMQ_CTL_DIST_PORT_MIN!"=="" (
+ if not "!CTL_DIST_PORT_MIN!"=="" (
+ set RABBITMQ_CTL_DIST_PORT_MIN=!CTL_DIST_PORT_MIN!
+ )
+)
+if "!RABBITMQ_CTL_DIST_PORT_MAX!"=="" (
+ if not "!CTL_DIST_PORT_MAX!"=="" (
+ set RABBITMQ_CTL_DIST_PORT_MAX=!CTL_DIST_PORT_MAX!
+ )
+)
+if "!RABBITMQ_CTL_DIST_PORT_MIN!"=="" (
+ set RABBITMQ_CTL_DIST_PORT_MIN=35672
+)
+if "!RABBITMQ_CTL_DIST_PORT_MAX!"=="" (
+ set /a RABBITMQ_CTL_DIST_PORT_MAX=10+!RABBITMQ_CTL_DIST_PORT_MIN!
+)
+
+REM ADDITIONAL WINDOWS ONLY CONFIG ITEMS
+
+if "!RABBITMQ_SERVICENAME!"=="" (
+ if "!SERVICENAME!"=="" (
+ set RABBITMQ_SERVICENAME=RabbitMQ
+ ) else (
+ set RABBITMQ_SERVICENAME=!SERVICENAME!
+ )
+)
+
+REM Environment cleanup
+set BOOT_MODULE=
+set CONFIG_FILE=
+set FEATURE_FLAGS_FILE=
+set ENABLED_PLUGINS_FILE=
+set LOG_BASE=
+set MNESIA_BASE=
+set PLUGINS_DIR=
+set SCRIPT_DIR=
+set SCRIPT_NAME=
+set TDP0=
+
+REM ##--- End of overridden <var_name> variables
+
+REM # Since we source this elsewhere, don't accidentally stop execution
+REM true
diff --git a/deps/rabbit/scripts/rabbitmq-plugins b/deps/rabbit/scripts/rabbitmq-plugins new file mode 100755 index 0000000000..1ec15b2ee9 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-plugins @@ -0,0 +1,23 @@ +#!/bin/sh +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +# Exit immediately if a pipeline, which may consist of a single simple command, +# a list, or a compound command returns a non-zero status +set -e + +# Each variable or function that is created or modified is given the export +# attribute and marked for export to the environment of subsequent commands. +set -a + +# shellcheck source=/dev/null +# +# TODO: when shellcheck adds support for relative paths, change to +# shellcheck source=./rabbitmq-env +. "${0%/*}"/rabbitmq-env + +run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmq-plugins "$@" diff --git a/deps/rabbit/scripts/rabbitmq-plugins.bat b/deps/rabbit/scripts/rabbitmq-plugins.bat new file mode 100644 index 0000000000..e1f13b7073 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-plugins.bat @@ -0,0 +1,56 @@ +@echo off
+
+REM This Source Code Form is subject to the terms of the Mozilla Public
+REM License, v. 2.0. If a copy of the MPL was not distributed with this
+REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
+REM
+REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
+REM
+
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+set STAR=%*
+setlocal enabledelayedexpansion
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "!TDP0!\rabbitmq-env.bat" %~n0
+
+if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B 1
+)
+
+REM Disable erl_crash.dump by default for control scripts.
+if not defined ERL_CRASH_DUMP_SECONDS (
+ set ERL_CRASH_DUMP_SECONDS=0
+)
+
+"!ERLANG_HOME!\bin\erl.exe" +B ^
+-boot !CLEAN_BOOT_FILE! ^
+-noinput -noshell -hidden -smp enable ^
+!RABBITMQ_CTL_ERL_ARGS! ^
+-kernel inet_dist_listen_min !RABBITMQ_CTL_DIST_PORT_MIN! ^
+-kernel inet_dist_listen_max !RABBITMQ_CTL_DIST_PORT_MAX! ^
+-run escript start ^
+-escript main rabbitmqctl_escript ^
+-extra "%RABBITMQ_HOME%\escript\rabbitmq-plugins" !STAR!
+
+if ERRORLEVEL 1 (
+ exit /B %ERRORLEVEL%
+)
+
+EXIT /B 0
+
+endlocal
+endlocal
diff --git a/deps/rabbit/scripts/rabbitmq-queues b/deps/rabbit/scripts/rabbitmq-queues new file mode 100755 index 0000000000..680076f962 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-queues @@ -0,0 +1,23 @@ +#!/bin/sh +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +# Exit immediately if a pipeline, which may consist of a single simple command, +# a list, or a compound command returns a non-zero status +set -e + +# Each variable or function that is created or modified is given the export +# attribute and marked for export to the environment of subsequent commands. +set -a + +# shellcheck source=/dev/null +# +# TODO: when shellcheck adds support for relative paths, change to +# shellcheck source=./rabbitmq-env +. "${0%/*}"/rabbitmq-env + +run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmq-queues "$@" diff --git a/deps/rabbit/scripts/rabbitmq-queues.bat b/deps/rabbit/scripts/rabbitmq-queues.bat new file mode 100644 index 0000000000..99fce6479f --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-queues.bat @@ -0,0 +1,56 @@ +@echo off
+REM This Source Code Form is subject to the terms of the Mozilla Public
+REM License, v. 2.0. If a copy of the MPL was not distributed with this
+REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
+REM
+REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
+REM
+
+REM Scopes the variables to the current batch file
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+set STAR=%*
+setlocal enabledelayedexpansion
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B 1
+)
+
+REM Disable erl_crash.dump by default for control scripts.
+if not defined ERL_CRASH_DUMP_SECONDS (
+ set ERL_CRASH_DUMP_SECONDS=0
+)
+
+"!ERLANG_HOME!\bin\erl.exe" +B ^
+-boot !CLEAN_BOOT_FILE! ^
+-noinput -noshell -hidden -smp enable ^
+!RABBITMQ_CTL_ERL_ARGS! ^
+-kernel inet_dist_listen_min !RABBITMQ_CTL_DIST_PORT_MIN! ^
+-kernel inet_dist_listen_max !RABBITMQ_CTL_DIST_PORT_MAX! ^
+-run escript start ^
+-escript main rabbitmqctl_escript ^
+-extra "%RABBITMQ_HOME%\escript\rabbitmq-queues" !STAR!
+
+if ERRORLEVEL 1 (
+ exit /B %ERRORLEVEL%
+)
+
+EXIT /B 0
+
+endlocal
+endlocal
diff --git a/deps/rabbit/scripts/rabbitmq-rel b/deps/rabbit/scripts/rabbitmq-rel new file mode 100755 index 0000000000..a96ec78764 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-rel @@ -0,0 +1,58 @@ +#!/usr/bin/env escript +%% vim:ft=erlang:sw=2:et: + +main(["show-rel"]) -> + Rel = get_rel(), + io:format("~p.~n", [Rel]); +main(["gen-boot"]) -> + generate_rel(), + generate_boot(). + +get_rel() -> + ok = application:load(rabbit), + Apps0 = get_apps(rabbit), + Apps1 = lists:sort( + fun + (_, rabbitmq_prelaunch) -> false; + (rabbitmq_prelaunch, _) -> true; + (_, mnesia) -> true; + (mnesia, _) -> false; + (A, B) -> A =< B + end, Apps0), + Apps = [{App, get_vsn(App)} || App <- Apps1], + + ERTSVersion = erlang:system_info(version), + RabbitVersion = get_vsn(rabbit), + + {release, + {"RabbitMQ", RabbitVersion}, + {erts, ERTSVersion}, + Apps}. + +get_apps(App) -> + ok = load_app(App), + {ok, DirectDeps} = application:get_key(App, applications), + lists:umerge( + [lists:usort(get_apps(Dep)) || Dep <- DirectDeps] ++ + [lists:usort([kernel, stdlib, sasl, App, mnesia])]). + +load_app(App) -> + case application:load(App) of + ok -> ok; + {error, {already_loaded, App}} -> ok + end. + +generate_rel() -> + Rel = get_rel(), + io:format("~p.~n", [Rel]), + Output = io_lib:format("~p.~n", [Rel]), + ok = file:write_file("rabbit.rel", Output). + +generate_boot() -> + Options = [local, {path, code:get_path()}], + ok = systools:make_script("rabbit", Options). + +get_vsn(App) -> + load_app(App), + {ok, Vsn} = application:get_key(App, vsn), + Vsn. diff --git a/deps/rabbit/scripts/rabbitmq-server b/deps/rabbit/scripts/rabbitmq-server new file mode 100755 index 0000000000..82058dcb26 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-server @@ -0,0 +1,155 @@ +#!/bin/sh +# vim:sw=4:et: +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +set -e + +# Get default settings with user overrides for (RABBITMQ_)<var_name> +# Non-empty defaults should be set in rabbitmq-env +SCRIPTS_DIR=$(dirname "$0") +. "$SCRIPTS_DIR/rabbitmq-env" + +[ "$NOTIFY_SOCKET" ] && RUNNING_UNDER_SYSTEMD=true + +RABBITMQ_DEFAULT_ALLOC_ARGS="+MBas ageffcbf +MHas ageffcbf +MBlmbcs 512 +MHlmbcs 512 +MMmcs 30" + +# Bump ETS table limit to 50000 +if [ "x" = "x$ERL_MAX_ETS_TABLES" ]; then + ERL_MAX_ETS_TABLES=50000 +fi + +check_start_params() { + check_not_empty RABBITMQ_BOOT_MODULE + check_not_empty SASL_BOOT_FILE +} + +check_not_empty() { + local name="${1:?}" + local value + eval value=\$$name + if [ -z "$value" ]; then + echo "Error: ENV variable should be defined: $1. + Please check rabbitmq-env, rabbitmq-defaults, and ${RABBITMQ_CONF_ENV_FILE} script files" + exit 78 + fi +} + +start_rabbitmq_server() { + set -e + + _rmq_env_set_erl_libs + + RABBITMQ_START_RABBIT= + [ "x" = "x$RABBITMQ_ALLOW_INPUT" ] && RABBITMQ_START_RABBIT=" -noinput" + if test -z "$RABBITMQ_NODE_ONLY"; then + if test "$USE_RABBIT_BOOT_SCRIPT"; then + # TODO: This is experimental and undocumented at this point. + # It is here just to do simple checks while playing with how + # RabbitMQ is started. + "$SCRIPTS_DIR/rabbitmq-rel" gen-boot + SASL_BOOT_FILE=rabbit + test -f "$SASL_BOOT_FILE.boot" + RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -init_debug" + else + RABBITMQ_START_RABBIT="$RABBITMQ_START_RABBIT -s $RABBITMQ_BOOT_MODULE boot" + fi + fi + + # We need to turn off path expansion because some of the vars, + # notably RABBITMQ_SERVER_ERL_ARGS, contain terms that look like + # globs and there is no other way of preventing their expansion. + set -f + + export ERL_MAX_ETS_TABLES \ + SYS_PREFIX + + check_start_params + + exec erl \ + -pa "$RABBITMQ_SERVER_CODE_PATH" \ + ${RABBITMQ_START_RABBIT} \ + -boot "${SASL_BOOT_FILE}" \ + +W w \ + ${RABBITMQ_DEFAULT_ALLOC_ARGS} \ + ${RABBITMQ_SERVER_ERL_ARGS} \ + ${RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS} \ + ${RABBITMQ_SERVER_START_ARGS} \ + -lager crash_log false \ + -lager handlers '[]' \ + "$@" +} + +stop_rabbitmq_server() { + if test "$rabbitmq_server_pid"; then + kill -TERM "$rabbitmq_server_pid" + wait "$rabbitmq_server_pid" || true + fi +} + +if [ "$RABBITMQ_ALLOW_INPUT" -o "$RUNNING_UNDER_SYSTEMD" -o "$detached" ]; then + # Run erlang VM directly, completely replacing current shell + # process - so the pid file written in the code above will be + # valid (unless detached, which is also handled in the code + # above). + # + # And also this is the correct mode to run the broker under + # systemd - there is no need in a proxy process that converts + # signals to graceful shutdown command, the unit file should already + # contain instructions for graceful shutdown. Also by removing + # this additional process we could simply use value returned by + # `os:getpid/0` for a systemd ready notification. + start_rabbitmq_server "$@" +else + # When RabbitMQ runs in the foreground but the Erlang shell is + # disabled, we setup signal handlers to stop RabbitMQ properly. This + # is at least useful in the case of Docker. + # The Erlang VM should ignore SIGINT. + RABBITMQ_SERVER_START_ARGS="${RABBITMQ_SERVER_START_ARGS} ${RABBITMQ_IGNORE_SIGINT_FLAG}" + + # Signal handlers. They all stop RabbitMQ properly, using + # rabbitmqctl stop. This script will exit with different exit codes: + # SIGHUP, SIGTSTP + SIGCONT + # Ignored until we implement a useful behavior. + # SIGTERM + # Exits 0 since this is considered a normal process termination. + # SIGINT + # Exits 128 + $signal_number where $signal_number is 2 for SIGINT (see + # https://pubs.opengroup.org/onlinepubs/009695399/utilities/kill.html). + # This is considered an abnormal process termination. Normally, we + # don't need to specify this exit code because the shell propagates it. + # Unfortunately, the signal handler doesn't work as expected in Dash, + # thus we need to explicitly restate the exit code. + # + # The behaviors below should remain consistent with the + # equivalent signal handlers in the Erlang code + # (see apps/rabbitmq_prelaunch/src/rabbit_prelaunch_sighandler.erl). + trap '' HUP TSTP CONT + trap "stop_rabbitmq_server; exit 0" TERM + trap "stop_rabbitmq_server; exit 130" INT + + start_rabbitmq_server "$@" & + export rabbitmq_server_pid=$! + + # Block until RabbitMQ exits or a signal is caught. + # Waits for last command (which is start_rabbitmq_server) + # + # The "|| true" is here to work around an issue with Dash. Normally + # in a Bourne shell, if `wait` is interrupted by a signal, the + # signal handlers defined above are executed and the script + # terminates with the exit code of `wait` (unless the signal handler + # overrides that). + # In the case of Dash, it looks like `set -e` (set at the beginning + # of this script) gets precedence over signal handling. Therefore, + # when `wait` is interrupted, its exit code is non-zero and because + # of `set -e`, the script terminates immediately without running the + # signal handler. To work around this issue, we use "|| true" to + # force that statement to succeed and the signal handler to properly + # execute. Because the statement below has an exit code of 0, the + # signal handler has to restate the expected exit code. + wait "$rabbitmq_server_pid" || true +fi diff --git a/deps/rabbit/scripts/rabbitmq-server.bat b/deps/rabbit/scripts/rabbitmq-server.bat new file mode 100644 index 0000000000..3a386b63c4 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-server.bat @@ -0,0 +1,91 @@ +@echo off
+REM This Source Code Form is subject to the terms of the Mozilla Public
+REM License, v. 2.0. If a copy of the MPL was not distributed with this
+REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
+REM
+REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
+REM
+
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+set STAR=%*
+set CONF_SCRIPT_DIR=%~dp0
+setlocal enabledelayedexpansion
+setlocal enableextensions
+
+if ERRORLEVEL 1 (
+ echo "Failed to enable command extensions!"
+ exit /B 1
+)
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B 1
+)
+
+set RABBITMQ_DEFAULT_ALLOC_ARGS=+MBas ageffcbf +MHas ageffcbf +MBlmbcs 512 +MHlmbcs 512 +MMmcs 30
+
+set RABBITMQ_START_RABBIT=
+if "!RABBITMQ_ALLOW_INPUT!"=="" (
+ set RABBITMQ_START_RABBIT=!RABBITMQ_START_RABBIT! -noinput
+)
+if "!RABBITMQ_NODE_ONLY!"=="" (
+ set RABBITMQ_START_RABBIT=!RABBITMQ_START_RABBIT! -s "!RABBITMQ_BOOT_MODULE!" boot
+)
+
+set ENV_OK=true
+CALL :check_not_empty "RABBITMQ_BOOT_MODULE" !RABBITMQ_BOOT_MODULE!
+
+if "!ENV_OK!"=="false" (
+ EXIT /b 78
+)
+
+if "!RABBITMQ_ALLOW_INPUT!"=="" (
+ set ERL_CMD=erl.exe
+) else (
+ set ERL_CMD=werl.exe
+)
+
+"!ERLANG_HOME!\bin\!ERL_CMD!" ^
+!RABBITMQ_START_RABBIT! ^
+-boot "!SASL_BOOT_FILE!" ^
++W w ^
+!RABBITMQ_DEFAULT_ALLOC_ARGS! ^
+!RABBITMQ_SERVER_ERL_ARGS! ^
+!RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS! ^
+!RABBITMQ_SERVER_START_ARGS! ^
+-lager crash_log false ^
+-lager handlers "[]" ^
+!STAR!
+
+if ERRORLEVEL 1 (
+ exit /B %ERRORLEVEL%
+)
+
+EXIT /B 0
+
+:check_not_empty
+if "%~2"=="" (
+ ECHO "Error: ENV variable should be defined: %1. Please check rabbitmq-env and rabbitmq-defaults, and !RABBITMQ_CONF_ENV_FILE! script files. Check also your Environment Variables settings"
+ set ENV_OK=false
+ EXIT /B 78
+ )
+EXIT /B 0
+
+endlocal
+endlocal
+endlocal
diff --git a/deps/rabbit/scripts/rabbitmq-service.bat b/deps/rabbit/scripts/rabbitmq-service.bat new file mode 100644 index 0000000000..0b7906d4bf --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-service.bat @@ -0,0 +1,271 @@ +@echo off
+REM This Source Code Form is subject to the terms of the Mozilla Public
+REM License, v. 2.0. If a copy of the MPL was not distributed with this
+REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
+REM
+REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
+REM
+
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TN0=%~n0
+set TDP0=%~dp0
+set CONF_SCRIPT_DIR=%~dp0
+set P1=%1
+setlocal enabledelayedexpansion
+setlocal enableextensions
+
+if ERRORLEVEL 1 (
+ echo "Failed to enable command extensions!"
+ exit /B 1
+)
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+REM Check for the short names here too
+if "!RABBITMQ_USE_LONGNAME!"=="true" (
+ set RABBITMQ_NAME_TYPE=-name
+ set NAMETYPE=longnames
+) else (
+ if "!USE_LONGNAME!"=="true" (
+ set RABBITMQ_USE_LONGNAME=true
+ set RABBITMQ_NAME_TYPE=-name
+ set NAMETYPE=longnames
+ ) else (
+ set RABBITMQ_USE_LONGNAME=false
+ set RABBITMQ_NAME_TYPE=-sname
+ set NAMETYPE=shortnames
+ )
+)
+
+REM [ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME}
+if "!RABBITMQ_NODENAME!"=="" (
+ if "!NODENAME!"=="" (
+ REM We use Erlang to query the local hostname because
+ REM !COMPUTERNAME! and Erlang may return different results.
+ REM Start erl with -sname to make sure epmd is started.
+ call "%ERLANG_HOME%\bin\erl.exe" -A0 -noinput -boot start_clean -sname rabbit-prelaunch-epmd -eval "init:stop()." >nul 2>&1
+ for /f "delims=" %%F in ('call "%ERLANG_HOME%\bin\erl.exe" -A0 -noinput -boot start_clean -eval "net_kernel:start([list_to_atom(""rabbit-gethostname-"" ++ os:getpid()), %NAMETYPE%]), [_, H] = string:tokens(atom_to_list(node()), ""@""), io:format(""~s~n"", [H]), init:stop()."') do @set HOSTNAME=%%F
+ set RABBITMQ_NODENAME=rabbit@!HOSTNAME!
+ set HOSTNAME=
+ ) else (
+ set RABBITMQ_NODENAME=!NODENAME!
+ )
+)
+set NAMETYPE=
+
+REM Set Erlang distribution port, based on the AMQP TCP port.
+REM
+REM We do this only for the Windows service because in this case, the node has
+REM to start with the distribution enabled on the command line. For all other
+REM cases, distribution is configured at runtime.
+if "!RABBITMQ_NODE_PORT!"=="" (
+ if not "!NODE_PORT!"=="" (
+ set RABBITMQ_NODE_PORT=!NODE_PORT!
+ ) else (
+ set RABBITMQ_NODE_PORT=5672
+ )
+)
+
+if "!RABBITMQ_DIST_PORT!"=="" (
+ if "!DIST_PORT!"=="" (
+ if "!RABBITMQ_NODE_PORT!"=="" (
+ set RABBITMQ_DIST_PORT=25672
+ ) else (
+ set /a RABBITMQ_DIST_PORT=20000+!RABBITMQ_NODE_PORT!
+ )
+ ) else (
+ set RABBITMQ_DIST_PORT=!DIST_PORT!
+ )
+)
+
+set RABBITMQ_DIST_ARG=-kernel inet_dist_listen_min !RABBITMQ_DIST_PORT! -kernel inet_dist_listen_max !RABBITMQ_DIST_PORT!
+
+set STARVAR=
+shift
+:loop1
+if "%1"=="" goto after_loop
+ set STARVAR=%STARVAR% %1
+ shift
+goto loop1
+:after_loop
+
+if "!ERLANG_SERVICE_MANAGER_PATH!"=="" (
+ if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B
+ )
+ for /f "delims=" %%i in ('dir /ad/b "!ERLANG_HOME!"') do if exist "!ERLANG_HOME!\%%i\bin\erlsrv.exe" (
+ set ERLANG_SERVICE_MANAGER_PATH=!ERLANG_HOME!\%%i\bin
+ )
+)
+
+set CONSOLE_FLAG=
+set CONSOLE_LOG_VALID=
+for %%i in (new reuse) do if "%%i" == "!RABBITMQ_CONSOLE_LOG!" set CONSOLE_LOG_VALID=TRUE
+if "!CONSOLE_LOG_VALID!" == "TRUE" (
+ set CONSOLE_FLAG=-debugtype !RABBITMQ_CONSOLE_LOG!
+)
+
+rem *** End of configuration ***
+
+if not exist "!ERLANG_SERVICE_MANAGER_PATH!\erlsrv.exe" (
+ echo.
+ echo **********************************************
+ echo ERLANG_SERVICE_MANAGER_PATH not set correctly.
+ echo **********************************************
+ echo.
+ echo "!ERLANG_SERVICE_MANAGER_PATH!\erlsrv.exe" not found
+ echo Please set ERLANG_SERVICE_MANAGER_PATH to the folder containing "erlsrv.exe".
+ echo.
+ exit /B 1
+)
+
+if "!P1!" == "install" goto INSTALL_SERVICE
+for %%i in (start stop) do if "%%i" == "!P1!" goto START_STOP_SERVICE
+for %%i in (disable enable list remove) do if "%%i" == "!P1!" goto MODIFY_SERVICE
+
+echo.
+echo *********************
+echo Service control usage
+echo *********************
+echo.
+echo !TN0! help - Display this help
+echo !TN0! install - Install the !RABBITMQ_SERVICENAME! service
+echo !TN0! remove - Remove the !RABBITMQ_SERVICENAME! service
+echo.
+echo The following actions can also be accomplished by using
+echo Windows Services Management Console (services.msc):
+echo.
+echo !TN0! start - Start the !RABBITMQ_SERVICENAME! service
+echo !TN0! stop - Stop the !RABBITMQ_SERVICENAME! service
+echo !TN0! disable - Disable the !RABBITMQ_SERVICENAME! service
+echo !TN0! enable - Enable the !RABBITMQ_SERVICENAME! service
+echo.
+exit /B
+
+
+:INSTALL_SERVICE
+
+if not exist "!RABBITMQ_BASE!" (
+ echo Creating base directory !RABBITMQ_BASE! & mkdir "!RABBITMQ_BASE!"
+)
+
+"!ERLANG_SERVICE_MANAGER_PATH!\erlsrv" list !RABBITMQ_SERVICENAME! 2>NUL 1>NUL
+if errorlevel 1 (
+ "!ERLANG_SERVICE_MANAGER_PATH!\erlsrv" add !RABBITMQ_SERVICENAME! -internalservicename !RABBITMQ_SERVICENAME!
+) else (
+ echo !RABBITMQ_SERVICENAME! service is already present - only updating service parameters
+)
+
+set RABBITMQ_DEFAULT_ALLOC_ARGS=+MBas ageffcbf +MHas ageffcbf +MBlmbcs 512 +MHlmbcs 512 +MMmcs 30
+
+set RABBITMQ_START_RABBIT=
+if "!RABBITMQ_NODE_ONLY!"=="" (
+ set RABBITMQ_START_RABBIT=-s "!RABBITMQ_BOOT_MODULE!" boot
+)
+
+if "!RABBITMQ_SERVICE_RESTART!"=="" (
+ set RABBITMQ_SERVICE_RESTART=restart
+)
+
+set ENV_OK=true
+CALL :check_not_empty "RABBITMQ_BOOT_MODULE" !RABBITMQ_BOOT_MODULE!
+CALL :check_not_empty "RABBITMQ_NAME_TYPE" !RABBITMQ_NAME_TYPE!
+CALL :check_not_empty "RABBITMQ_NODENAME" !RABBITMQ_NODENAME!
+
+if "!ENV_OK!"=="false" (
+ EXIT /b 78
+)
+
+set ERLANG_SERVICE_ARGUMENTS= ^
+!RABBITMQ_START_RABBIT! ^
+-boot "!SASL_BOOT_FILE!" ^
++W w ^
+!RABBITMQ_DEFAULT_ALLOC_ARGS! ^
+!RABBITMQ_SERVER_ERL_ARGS! ^
+!RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS! ^
+!RABBITMQ_SERVER_START_ARGS! ^
+!RABBITMQ_DIST_ARG! ^
+-lager crash_log false ^
+-lager handlers "[]" ^
+!STARVAR!
+
+set ERLANG_SERVICE_ARGUMENTS=!ERLANG_SERVICE_ARGUMENTS:\=\\!
+set ERLANG_SERVICE_ARGUMENTS=!ERLANG_SERVICE_ARGUMENTS:"=\"!
+
+rem We resolve %APPDATA% at install time so that the user's %APPDATA%
+rem is passed to `rabbit_env` at runtime (instead of the service's
+rem %APPDAT%).
+rem
+rem The goal is to keep the same behavior as when RabbitMQ data
+rem locations were decided in `rabbitmq-env.bat` (sourced by this
+rem script), even if now, we compute everything in `rabbit_env` at
+rem runtime.
+rem
+rem We may revisit this in the future so that no data is stored in a
+rem user-specific directory.
+"!ERLANG_SERVICE_MANAGER_PATH!\erlsrv" set !RABBITMQ_SERVICENAME! ^
+-onfail !RABBITMQ_SERVICE_RESTART! ^
+-machine "!ERLANG_SERVICE_MANAGER_PATH!\erl.exe" ^
+-env APPDATA="!APPDATA!" ^
+-env ERL_LIBS="!ERL_LIBS!" ^
+-env ERL_MAX_ETS_TABLES="!ERL_MAX_ETS_TABLES!" ^
+-env ERL_MAX_PORTS="!ERL_MAX_PORTS!" ^
+-workdir "!RABBITMQ_BASE!" ^
+-stopaction "rabbit:stop_and_halt()." ^
+!RABBITMQ_NAME_TYPE! !RABBITMQ_NODENAME! ^
+!CONSOLE_FLAG! ^
+-comment "Multi-protocol open source messaging broker" ^
+-args "!ERLANG_SERVICE_ARGUMENTS!" > NUL
+
+if ERRORLEVEL 1 (
+ EXIT /B 1
+)
+goto END
+
+
+:MODIFY_SERVICE
+
+"!ERLANG_SERVICE_MANAGER_PATH!\erlsrv" !P1! !RABBITMQ_SERVICENAME!
+if ERRORLEVEL 1 (
+ EXIT /B 1
+)
+goto END
+
+
+:START_STOP_SERVICE
+
+REM start and stop via erlsrv reports no error message. Using net instead
+net !P1! !RABBITMQ_SERVICENAME!
+if ERRORLEVEL 1 (
+ EXIT /B 1
+)
+goto END
+
+:END
+
+EXIT /B 0
+
+:check_not_empty
+if "%~2"=="" (
+ ECHO "Error: ENV variable should be defined: %1. Please check rabbitmq-env, rabbitmq-default, and !RABBITMQ_CONF_ENV_FILE! script files. Check also your Environment Variables settings"
+ set ENV_OK=false
+ EXIT /B 78
+ )
+EXIT /B 0
+
+endlocal
+endlocal
+endlocal
diff --git a/deps/rabbit/scripts/rabbitmq-streams b/deps/rabbit/scripts/rabbitmq-streams new file mode 100755 index 0000000000..376cc497df --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-streams @@ -0,0 +1,32 @@ +#!/bin/sh +## The contents of this file are subject to the Mozilla Public License +## Version 1.1 (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License +## at https://www.mozilla.org/MPL/ +## +## Software distributed under the License is distributed on an "AS IS" +## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +## the License for the specific language governing rights and +## limitations under the License. +## +## The Original Code is RabbitMQ. +## +## The Initial Developer of the Original Code is GoPivotal, Inc. +## Copyright (c) 2007-2020 Pivotal Software, Inc. All rights reserved. +## + +# Exit immediately if a pipeline, which may consist of a single simple command, +# a list, or a compound command returns a non-zero status +set -e + +# Each variable or function that is created or modified is given the export +# attribute and marked for export to the environment of subsequent commands. +set -a + +# shellcheck source=/dev/null +# +# TODO: when shellcheck adds support for relative paths, change to +# shellcheck source=./rabbitmq-env +. "${0%/*}"/rabbitmq-env + +run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmq-streams "$@" diff --git a/deps/rabbit/scripts/rabbitmq-streams.bat b/deps/rabbit/scripts/rabbitmq-streams.bat new file mode 100644 index 0000000000..83572a8d62 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-streams.bat @@ -0,0 +1,63 @@ +@echo off
+REM The contents of this file are subject to the Mozilla Public License
+REM Version 1.1 (the "License"); you may not use this file except in
+REM compliance with the License. You may obtain a copy of the License
+REM at https://www.mozilla.org/MPL/
+REM
+REM Software distributed under the License is distributed on an "AS IS"
+REM basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+REM the License for the specific language governing rights and
+REM limitations under the License.
+REM
+REM The Original Code is RabbitMQ.
+REM
+REM The Initial Developer of the Original Code is GoPivotal, Inc.
+REM Copyright (c) 2007-2020 Pivotal Software, Inc. All rights reserved.
+REM
+
+REM Scopes the variables to the current batch file
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+set STAR=%*
+setlocal enabledelayedexpansion
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B 1
+)
+
+REM Disable erl_crash.dump by default for control scripts.
+if not defined ERL_CRASH_DUMP_SECONDS (
+ set ERL_CRASH_DUMP_SECONDS=0
+)
+
+"!ERLANG_HOME!\bin\erl.exe" +B ^
+-boot !CLEAN_BOOT_FILE! ^
+-noinput -noshell -hidden -smp enable ^
+!RABBITMQ_CTL_ERL_ARGS! ^
+-run escript start ^
+-escript main rabbitmqctl_escript ^
+-extra "%RABBITMQ_HOME%\escript\rabbitmq-streams" !STAR!
+
+if ERRORLEVEL 1 (
+ exit /B %ERRORLEVEL%
+)
+
+EXIT /B 0
+
+endlocal
+endlocal
diff --git a/deps/rabbit/scripts/rabbitmq-upgrade b/deps/rabbit/scripts/rabbitmq-upgrade new file mode 100755 index 0000000000..6d2bc3f948 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-upgrade @@ -0,0 +1,23 @@ +#!/bin/sh +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +# Exit immediately if a pipeline, which may consist of a single simple command, +# a list, or a compound command returns a non-zero status +set -e + +# Each variable or function that is created or modified is given the export +# attribute and marked for export to the environment of subsequent commands. +set -a + +# shellcheck source=/dev/null +# +# TODO: when shellcheck adds support for relative paths, change to +# shellcheck source=./rabbitmq-env +. "${0%/*}"/rabbitmq-env + +run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmq-upgrade "$@" diff --git a/deps/rabbit/scripts/rabbitmq-upgrade.bat b/deps/rabbit/scripts/rabbitmq-upgrade.bat new file mode 100644 index 0000000000..70b0eeee62 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmq-upgrade.bat @@ -0,0 +1,55 @@ +@echo off +REM This Source Code Form is subject to the terms of the Mozilla Public +REM License, v. 2.0. If a copy of the MPL was not distributed with this +REM file, You can obtain one at https://mozilla.org/MPL/2.0/. +REM +REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +REM + +REM Scopes the variables to the current batch file +setlocal + +rem Preserve values that might contain exclamation marks before +rem enabling delayed expansion +set TDP0=%~dp0 +set STAR=%* +setlocal enabledelayedexpansion + +REM Get default settings with user overrides for (RABBITMQ_)<var_name> +REM Non-empty defaults should be set in rabbitmq-env +call "%TDP0%\rabbitmq-env.bat" %~n0 + +if not exist "!ERLANG_HOME!\bin\erl.exe" ( + echo. + echo ****************************** + echo ERLANG_HOME not set correctly. + echo ****************************** + echo. + echo Please either set ERLANG_HOME to point to your Erlang installation or place the + echo RabbitMQ server distribution in the Erlang lib folder. + echo. + exit /B 1 +) + +REM Disable erl_crash.dump by default for control scripts. +if not defined ERL_CRASH_DUMP_SECONDS ( + set ERL_CRASH_DUMP_SECONDS=0 +) + +"!ERLANG_HOME!\bin\erl.exe" +B ^ +-boot !CLEAN_BOOT_FILE! ^ +-noinput -noshell -hidden -smp enable ^ +!RABBITMQ_CTL_ERL_ARGS! ^ +-kernel inet_dist_listen_min !RABBITMQ_CTL_DIST_PORT_MIN! ^ +-kernel inet_dist_listen_max !RABBITMQ_CTL_DIST_PORT_MAX! ^ +-run escript start ^ +-escript main rabbitmqctl_escript ^ +-extra "%RABBITMQ_HOME%\escript\rabbitmq-upgrade" !STAR! + +if ERRORLEVEL 1 ( + exit /B %ERRORLEVEL% +) + +EXIT /B 0 + +endlocal diff --git a/deps/rabbit/scripts/rabbitmqctl b/deps/rabbit/scripts/rabbitmqctl new file mode 100755 index 0000000000..8016dbe282 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmqctl @@ -0,0 +1,23 @@ +#!/bin/sh +## This Source Code Form is subject to the terms of the Mozilla Public +## License, v. 2.0. If a copy of the MPL was not distributed with this +## file, You can obtain one at https://mozilla.org/MPL/2.0/. +## +## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +## + +# Exit immediately if a pipeline, which may consist of a single simple command, +# a list, or a compound command returns a non-zero status +set -e + +# Each variable or function that is created or modified is given the export +# attribute and marked for export to the environment of subsequent commands. +set -a + +# shellcheck source=/dev/null +# +# TODO: when shellcheck adds support for relative paths, change to +# shellcheck source=./rabbitmq-env +. "${0%/*}"/rabbitmq-env + +run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmqctl "$@" diff --git a/deps/rabbit/scripts/rabbitmqctl.bat b/deps/rabbit/scripts/rabbitmqctl.bat new file mode 100644 index 0000000000..711ec6e990 --- /dev/null +++ b/deps/rabbit/scripts/rabbitmqctl.bat @@ -0,0 +1,56 @@ +@echo off
+REM This Source Code Form is subject to the terms of the Mozilla Public
+REM License, v. 2.0. If a copy of the MPL was not distributed with this
+REM file, You can obtain one at https://mozilla.org/MPL/2.0/.
+REM
+REM Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
+REM
+
+REM Scopes the variables to the current batch file
+setlocal
+
+rem Preserve values that might contain exclamation marks before
+rem enabling delayed expansion
+set TDP0=%~dp0
+set STAR=%*
+setlocal enabledelayedexpansion
+
+REM Get default settings with user overrides for (RABBITMQ_)<var_name>
+REM Non-empty defaults should be set in rabbitmq-env
+call "%TDP0%\rabbitmq-env.bat" %~n0
+
+if not exist "!ERLANG_HOME!\bin\erl.exe" (
+ echo.
+ echo ******************************
+ echo ERLANG_HOME not set correctly.
+ echo ******************************
+ echo.
+ echo Please either set ERLANG_HOME to point to your Erlang installation or place the
+ echo RabbitMQ server distribution in the Erlang lib folder.
+ echo.
+ exit /B 1
+)
+
+REM Disable erl_crash.dump by default for control scripts.
+if not defined ERL_CRASH_DUMP_SECONDS (
+ set ERL_CRASH_DUMP_SECONDS=0
+)
+
+"!ERLANG_HOME!\bin\erl.exe" +B ^
+-boot !CLEAN_BOOT_FILE! ^
+-noinput -noshell -hidden -smp enable ^
+!RABBITMQ_CTL_ERL_ARGS! ^
+-kernel inet_dist_listen_min !RABBITMQ_CTL_DIST_PORT_MIN! ^
+-kernel inet_dist_listen_max !RABBITMQ_CTL_DIST_PORT_MAX! ^
+-run escript start ^
+-escript main rabbitmqctl_escript ^
+-extra "%RABBITMQ_HOME%\escript\rabbitmqctl" !STAR!
+
+if ERRORLEVEL 1 (
+ exit /B %ERRORLEVEL%
+)
+
+EXIT /B 0
+
+endlocal
+endlocal
|