diff options
author | Emile Joubert <emile@lshift.net> | 2008-11-14 00:03:39 +0000 |
---|---|---|
committer | Emile Joubert <emile@lshift.net> | 2008-11-14 00:03:39 +0000 |
commit | 4646889600500993c5a69c6f6640b6175da97c8a (patch) | |
tree | c5f545dd30bd84693a7a0d7c36ecad065aeedd5e | |
parent | 05e8da946fae7154c97a2b19b1d1b0bdf7207c3a (diff) | |
parent | c20d4e8033060497dc4843e47f09134a79914970 (diff) | |
download | rabbitmq-server-4646889600500993c5a69c6f6640b6175da97c8a.tar.gz |
Merged bug18381 into bug19684
-rw-r--r-- | packaging/Makefile | 3 | ||||
-rwxr-xr-x | packaging/checks.sh | 45 | ||||
-rw-r--r-- | packaging/debs/Debian/Makefile | 1 | ||||
-rw-r--r-- | packaging/windows/Makefile | 4 | ||||
-rw-r--r-- | packaging/windows/rabbitmq-service.pod | 138 | ||||
-rwxr-xr-x | scripts/rabbitmq-service.bat | 190 | ||||
-rw-r--r-- | src/rabbit_control.erl | 27 |
7 files changed, 358 insertions, 50 deletions
diff --git a/packaging/Makefile b/packaging/Makefile deleted file mode 100644 index 44a9b328..00000000 --- a/packaging/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -check_tools: - @sh ./checks.sh - @echo All the needed tools seem to be installed, great! diff --git a/packaging/checks.sh b/packaging/checks.sh deleted file mode 100755 index 63e88701..00000000 --- a/packaging/checks.sh +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh - -# We check for the presence of the tools necessary to build a release on a -# Debian based OS. - -TOOLS_STOP=0 - -checker () { - if [ ! `which $1` ] - then - echo "$1 is missing, please install it" - TOOLS_STOP=1 - NEW_NAME=`echo $1 | sed -e 's/-/_/g'` - eval "$NEW_NAME=1" - else - echo "$1 found" - fi -}; - -echo ~~~~~~~~~~~~ Looking for mandatory programs ~~~~~~~~~~~~ - -for i in cdbs-edit-patch reprepro rpm elinks wget zip gpg rsync -do - checker $i -done -echo ~~~~~~~~~~~~~~~~~~~~~~~~~~ DONE ~~~~~~~~~~~~~~~~~~~~~~~ - -if [ 1 = $TOOLS_STOP ] -then - [ $cdbs_edit_patch ] && cdbs_edit_patch="cdbs " - [ $reprepro ] && reprepro="reprepro " - [ $rpm ] && rpm="rpm " - [ $elinks ] && elinks="elinks " - [ $wget ] && wget="wget " - [ $zip ] && zip="zip " - [ $gpg ] && gpg="gpg " - [ $rsync ] && rsync="rsync " - - echo - echo We suggest you run the command - echo "apt-get install ${cdbs_edit_patch}${reprepro}${rpm}${elinks}${wget}${zip}${gpg}${rsync}" - echo -fi - -exit $TOOLS_STOP diff --git a/packaging/debs/Debian/Makefile b/packaging/debs/Debian/Makefile index 3e74cb52..9479feb0 100644 --- a/packaging/debs/Debian/Makefile +++ b/packaging/debs/Debian/Makefile @@ -16,7 +16,6 @@ all: @echo 'Please choose a target from the Makefile.' package: clean - make -C ../.. check_tools cp $(TARBALL_DIR)/$(TARBALL) $(DEBIAN_ORIG_TARBALL) tar -zxvf $(DEBIAN_ORIG_TARBALL) cp -r debian $(UNPACKED_DIR) diff --git a/packaging/windows/Makefile b/packaging/windows/Makefile index f9437da7..b052f40a 100644 --- a/packaging/windows/Makefile +++ b/packaging/windows/Makefile @@ -2,6 +2,7 @@ VERSION=0.0.0 SOURCE_DIR=rabbitmq-server-$(VERSION) TARGET_DIR=rabbitmq_server-$(VERSION) TARGET_ZIP=rabbitmq-server-windows-$(VERSION) +TOP_DIR=$(shell pwd) dist: make -C ../.. VERSION=$(VERSION) srcdist @@ -10,6 +11,7 @@ dist: mkdir $(SOURCE_DIR)/sbin mv $(SOURCE_DIR)/scripts/rabbitmq-server.bat $(SOURCE_DIR)/sbin + mv $(SOURCE_DIR)/scripts/rabbitmq-service.bat $(SOURCE_DIR)/sbin mv $(SOURCE_DIR)/scripts/rabbitmqctl.bat $(SOURCE_DIR)/sbin mv $(SOURCE_DIR)/scripts/rabbitmq-multi.bat $(SOURCE_DIR)/sbin rm -rf $(SOURCE_DIR)/scripts @@ -18,6 +20,8 @@ dist: rm -rf $(SOURCE_DIR)/docs mv $(SOURCE_DIR) $(TARGET_DIR) + pod2text --loose $(TOP_DIR)/rabbitmq-service.pod $(TARGET_DIR)/readme-service.txt + unix2dos $(TARGET_DIR)/readme-service.txt zip -r $(TARGET_ZIP).zip $(TARGET_DIR) rm -rf $(TARGET_DIR) diff --git a/packaging/windows/rabbitmq-service.pod b/packaging/windows/rabbitmq-service.pod new file mode 100644 index 00000000..d2ee48f9 --- /dev/null +++ b/packaging/windows/rabbitmq-service.pod @@ -0,0 +1,138 @@ +=head1 NAME + +rabbitmq-service - manage RabbitMQ AMQP service + +=head1 SYNOPSIS + +rabbitmq-service.bat command + +=head1 DESCRIPTION + +RabbitMQ is an implementation of AMQP, the emerging standard for high +performance enterprise messaging. The RabbitMQ server is a robust and +scalable implementation of an AMQP broker. + +Running B<rabbitmq-service> allows the RabbitMQ broker to be run as a +service on NT/2000/2003/XP/Vista® environments. The RabbitMQ broker +service can be started and stopped using the Windows® services +applet. + +By default the service will run in the authentication context of the +local system account. It is therefore necessary to synchronise Erlang +cookies between the local system account (typically +C<C:\WINDOWS\.erlang.cookie> and the account that will be used to +run B<rabbitctl>. + +=head1 COMMANDS + +=head2 help + +Display usage information. + +=head2 install + +Install the service. The service will not be started. +Subsequent invocations will update the service parameters if +relevant environment variables were modified. + +=head2 remove + +Remove the service. If the service is running then it will +automatically be stopped before being removed. No files will be +deleted as a consequence and B<rabbitmq-server> will remain operable. + +=head2 start + +Start the service. The service must have been correctly installed +beforehand. + +=head2 stop + +Stop the service. The service must be running for this command to +have any effect. + +=head2 disable + +Disable the service. This is the equivalent of setting the startup +type to B<Disabled> using the service control panel. + +=head2 enable + +Enable the service. This is the equivalent of setting the startup +type to B<Automatic> using the service control panel. + +=head1 ENVIRONMENT + +=head2 SERVICENAME + +Defaults to RabbitMQ. +This is the location of log and database directories. + +=head2 RABBITMQ_BASE + +Defaults to the application data directory of the current user. +This is the location of log and database directories. + +=head2 NODENAME + +Defaults to "rabbit". This can be useful if you want to run more +than one node per machine - B<NODENAME> should be unique per +erlang-node-and-machine combination. See clustering on a single +machine guide +at L<http://www.rabbitmq.com/clustering.html#single-machine> for +details. + +=head2 NODE_IP_ADDRESS + +Defaults to "0.0.0.0". This can be changed if you only want to bind +to one network interface. + +=head2 NODE_PORT + +Defaults to 5672. + +=head2 ERLANG_SERVICE_MANAGER_PATH + +Defaults to F<C:\Program Files\erl5.5.5\erts-5.5.5\bin>. This is +the installation location of the Erlang service manager. + +=head2 CLUSTER_CONFIG_FILE + +If this file is present it is used by the server to +auto-configure a RabbitMQ cluster. See the clustering guide +at L<http://www.rabbitmq.com/clustering.html> for details. + +=head2 CONSOLE_LOG + +Set this varable to B<new> or B<reuse> to have the console +output from the server redirected to a file named B<SERVICENAME>.debug +in the application data directory of the user that installed the service. +Under Vista this will be F<C:\Documents and Settings\User\AppData\username\SERVICENAME>. +Under previous versions of Windows this will be +F<C:\Documents and Settings\username\Application Data\SERVICENAME>. +If B<CONSOLE_LOG> is set to B<new> then a new file will be created +each time the service starts. If B<CONSOLE_LOG> is set to B<reuse> +then the file will be overwritten each time the service starts. +The default behaviour when B<CONSOLE_LOG> is not set or set to a +value other than B<new> or B<reuse> is to discard the server output. + +=head1 EXAMPLES + +Start a previously-installed RabbitMQ AMQP service: + + rabbitmq-service start + +=head1 AUTHOR + +Originally written by The RabbitMQ Team <info@lshift.net> + +=head1 COPYRIGHT + +This package, the RabbitMQ server is licensed under the MPL. + +If you have any questions regarding licensing, please contact us at +info@rabbitmq.com. + +=head1 REFERENCES + +RabbitMQ Web Site: http://www.rabbitmq.com diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat new file mode 100755 index 00000000..5a176726 --- /dev/null +++ b/scripts/rabbitmq-service.bat @@ -0,0 +1,190 @@ +@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 at
+REM http://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 the
+REM License for the specific language governing rights and limitations
+REM under the License.
+REM
+REM The Original Code is RabbitMQ.
+REM
+REM The Initial Developers of the Original Code are LShift Ltd.,
+REM Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.
+REM
+REM Portions created by LShift Ltd., Cohesive Financial Technologies
+REM LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008
+REM LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit
+REM Technologies Ltd.;
+REM
+REM All Rights Reserved.
+REM
+REM Contributor(s): ______________________________________.
+REM
+
+if "%SERVICENAME%"=="" (
+ set SERVICENAME=RabbitMQ
+)
+
+if "%RABBITMQ_BASE%"=="" (
+ set RABBITMQ_BASE=%APPDATA%\%SERVICENAME%
+)
+
+if "%NODENAME%"=="" (
+ set NODENAME=rabbit
+)
+
+if "%NODE_IP_ADDRESS%"=="" (
+ set NODE_IP_ADDRESS=0.0.0.0
+)
+
+if "%NODE_PORT%"=="" (
+ set NODE_PORT=5672
+)
+
+if "%ERLANG_SERVICE_MANAGER_PATH%"=="" (
+ set ERLANG_SERVICE_MANAGER_PATH=C:\Program Files\erl5.5.5\erts-5.5.5\bin
+)
+
+set CONSOLE_FLAG=
+set CONSOLE_LOG_VALID=
+for %%i in (new reuse) do if "%%i" == "%CONSOLE_LOG%" set CONSOLE_LOG_VALID=TRUE
+if "%CONSOLE_LOG_VALID%" == "TRUE" (
+ set CONSOLE_FLAG=-debugtype %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
+)
+
+rem erlang prefers forwardslash as separator in paths
+set RABBITMQ_BASE_UNIX=%RABBITMQ_BASE:\=/%
+set MNESIA_BASE=%RABBITMQ_BASE_UNIX%/db
+set LOG_BASE=%RABBITMQ_BASE_UNIX%/log
+
+
+rem We save the previous logs in their respective backup
+rem Log management (rotation, filtering based on size...) is left as an exercise for the user.
+
+set BACKUP_EXTENSION=.1
+
+set LOGS="%RABBITMQ_BASE%\log\%NODENAME%.log"
+set SASL_LOGS="%RABBITMQ_BASE%\log\%NODENAME%-sasl.log"
+
+set LOGS_BACKUP="%RABBITMQ_BASE%\log\%NODENAME%.log%BACKUP_EXTENSION%"
+set SASL_LOGS_BACKUP="%RABBITMQ_BASE%\log\%NODENAME%-sasl.log%BACKUP_EXTENSION%"
+
+if exist %LOGS% (
+ type %LOGS% >> %LOGS_BACKUP%
+)
+if exist %SASL_LOGS% (
+ type %SASL_LOGS% >> %SASL_LOGS_BACKUP%
+)
+
+rem End of log management
+
+
+set CLUSTER_CONFIG_FILE=%RABBITMQ_BASE%\rabbitmq_cluster.config
+set CLUSTER_CONFIG=
+if not exist "%CLUSTER_CONFIG_FILE%" GOTO L1
+set CLUSTER_CONFIG=-rabbit cluster_config \""%CLUSTER_CONFIG_FILE:\=/%"\"
+:L1
+
+set MNESIA_DIR=%MNESIA_BASE%/%NODENAME%-mnesia
+
+
+if "%1" == "install" goto INSTALL_SERVICE
+for %%i in (start stop disable enable list remove) do if "%%i" == "%1" goto MODIFY_SERVICE
+
+echo.
+echo *********************
+echo Service control usage
+echo *********************
+echo.
+echo %~n0 help - Display this help
+echo %~n0 install - Install the %SERVICENAME% service
+echo %~n0 remove - Remove the %SERVICENAME% service
+echo.
+echo The following actions can also be accomplished by using
+echo Windows Services Management Console (services.msc):
+echo.
+echo %~n0 start - Start the %SERVICENAME% service
+echo %~n0 stop - Stop the %SERVICENAME% service
+echo %~n0 disable - Disable the %SERVICENAME% service
+echo %~n0 enable - Enable the %SERVICENAME% service
+echo.
+exit /B
+
+
+:INSTALL_SERVICE
+
+if not exist "%RABBITMQ_BASE%" (
+ echo Creating base directory %RABBITMQ_BASE% & md "%RABBITMQ_BASE%"
+)
+
+"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" list %SERVICENAME% 2>NUL 1>NUL
+if errorlevel 1 (
+ "%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" add %SERVICENAME%
+) else (
+ echo %SERVICENAME% service is already present - only updating service parameters
+)
+
+set RABBIT_EBIN_TMP=%~dp0%
+set RABBIT_EBIN=%RABBIT_EBIN_TMP:\=/%../ebin
+
+set ERLANG_SERVICE_ARGUMENTS= ^
+-pa "%RABBIT_EBIN%" ^
+-boot start_sasl ^
+-s rabbit ^
++W w ^
++A30 ^
+-kernel inet_default_listen_options "[{nodelay,true},{sndbuf,16384},{recbuf,4096}]" ^
+-kernel inet_default_connect_options "[{nodelay,true}]" ^
+-rabbit tcp_listeners "[{\"%NODE_IP_ADDRESS%\",%NODE_PORT%}]" ^
+-kernel error_logger {file,\""%LOG_BASE%/%NODENAME%.log"\"} ^
+-sasl errlog_type error ^
+-sasl sasl_error_logger {file,\""%LOG_BASE%/%NODENAME%-sasl.log"\"} ^
+-os_mon start_cpu_sup true ^
+-os_mon start_disksup false ^
+-os_mon start_memsup true ^
+-os_mon start_os_sup false ^
+-os_mon memsup_system_only true ^
+-os_mon system_memory_high_watermark 0.95 ^
+-mnesia dir \""%MNESIA_DIR%"\" ^
+%CLUSTER_CONFIG% ^
+%RABBIT_ARGS% ^
+%*
+
+set ERLANG_SERVICE_ARGUMENTS=%ERLANG_SERVICE_ARGUMENTS:\=\\%
+set ERLANG_SERVICE_ARGUMENTS=%ERLANG_SERVICE_ARGUMENTS:"=\"%
+
+"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" set %SERVICENAME% ^
+-machine "%ERLANG_SERVICE_MANAGER_PATH%\erl.exe" ^
+-env ERL_CRASH_DUMP="%RABBITMQ_BASE_UNIX%/log" ^
+-workdir "%RABBITMQ_BASE%" ^
+-stopaction "rabbit:stop_and_halt()." ^
+-sname %NODENAME% ^
+%CONSOLE_FLAG% ^
+-args "%ERLANG_SERVICE_ARGUMENTS%" > NUL
+goto END
+
+
+:MODIFY_SERVICE
+
+"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" %1 %SERVICENAME%
+goto END
+
+
+:END
\ No newline at end of file diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index bc588279..d6f5ad73 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -89,12 +89,18 @@ Available commands: list_user_vhosts <UserName> list_vhost_users <VHostPath> + list_queues <InfoItem> [<InfoItem> ...] + <node> should be the name of the master node of the RabbitMQ cluster. It defaults to the node named \"rabbit\" on the local host. On a host named \"server.example.com\", the master node will usually be rabbit@server (unless NODENAME has been set to some non-default value at broker startup time). The output of hostname -s is usually the correct suffix to use after the \"@\" sign. +<InfoItem> must be a member of the list [name, durable, auto_delete, arguments, +pid, messages_ready, messages_unacknowledged, messages_uncommitted, messages, +acks_uncommitted, consumers, transactions, memory]. + "), halt(1). @@ -179,7 +185,26 @@ action(list_user_vhosts, Node, Args = [_Username]) -> action(list_vhost_users, Node, Args = [_VHostPath]) -> io:format("Listing users for vhosts ~p...", Args), - display_list(call(Node, {rabbit_access_control, list_vhost_users, Args})). + display_list(call(Node, {rabbit_access_control, list_vhost_users, Args})); + +action(list_queues, Node, Args) -> + io:format("Listing queues ...~n"), + lists:map( + fun (ResultRow) -> + lists:map( + fun(ResultColumn) -> + case ResultColumn of + {name, #resource{virtual_host = VHostPath, kind = queue, name = Name}} -> + io:format("~s@~s ", [Name, VHostPath]); + {_, Res} -> + io:format("~w ", [Res]) + end + end, + ResultRow), + io:nl() + end, + rpc_call(Node, rabbit_amqqueue, info_all, [[list_to_atom(X) || X <- Args]])), + ok. display_list(L) when is_list(L) -> lists:foreach(fun (I) -> |