diff options
author | Emile <emile@lshift.net> | 2008-10-07 10:02:52 +0100 |
---|---|---|
committer | Emile <emile@lshift.net> | 2008-10-07 10:02:52 +0100 |
commit | 8297d9d6452ce94635b508e39c8417d436c6d0cb (patch) | |
tree | 4f33915bdf20d4c21d2db3f9a85887a646b78972 | |
parent | 8c1a76ad5c03b66534444347bd8f3a9a3214a1e5 (diff) | |
download | rabbitmq-server-8297d9d6452ce94635b508e39c8417d436c6d0cb.tar.gz |
Run broker as windows service
-rw-r--r-- | docs/rabbitmq-service.pod | 114 | ||||
-rw-r--r-- | packaging/windows/Makefile | 1 | ||||
-rwxr-xr-x | scripts/rabbitmq-service.bat | 188 |
3 files changed, 303 insertions, 0 deletions
diff --git a/docs/rabbitmq-service.pod b/docs/rabbitmq-service.pod new file mode 100644 index 00000000..6805c8d4 --- /dev/null +++ b/docs/rabbitmq-service.pod @@ -0,0 +1,114 @@ +=head1 NAME + +rabbitmq-service - manage RabbitMQ AMQP service + +=head1 SYNOPSIS + +rabbitmq-service I<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 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 rabbitctl. + +=head1 COMMANDS + +B<help> + Display usage information. + +B<install> + Install the service. The service will not be started. + Subsequent invocations will update the service parameters if + relevant environment variables were modified. + +B<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 I<rabbitmq-server> will remain operable. + +B<start> + Start the service. The service must have been correctly installed + beforehand. + +B<stop> + Stop the service. The service must be running. + +B<disable> + Disable the service. This is the equivalent of setting the startup + type to I<Disabled> using the service control panel. + +B<enable> + Enable the service. This is the equivalent of setting the startup + type to I<Automatic> using the service control panel. + +=head1 ENVIRONMENT + +B<SERVICENAME> + Defaults to RabbitMQ. + This is the location of log and database directories. + +B<RABBITMQ_BASE> + Defaults to the application data directory of the current user. + This is the location of log and database directories. + +B<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 http://www.rabbitmq.com/clustering.html#single-machine for + details. + +B<NODE_IP_ADDRESS> + Defaults to 0.0.0.0. This can be changed if you only want to bind + to one network interface. + +B<NODE_PORT> + Defaults to 5672. + +B<ERLANG_SERVICE_MANAGER_PATH> + Defaults to C<C:\Program Files\erl5.5.5\erts-5.5.5\bin>. This is + the installation location of the Erlang service manager. + +B<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 http://www.rabbitmq.com/clustering.html for details. + + +=head1 EXAMPLES + +Start a previously-installed RabbitMQ AMQP service: + + rabbitmq-service start + +=head1 SEE ALSO + +rabbitmq-service(1), rabbitmqctl(1) + +=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/packaging/windows/Makefile b/packaging/windows/Makefile index f9437da7..1d6e1f6a 100644 --- a/packaging/windows/Makefile +++ b/packaging/windows/Makefile @@ -10,6 +10,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 diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat new file mode 100755 index 00000000..8af9ee38 --- /dev/null +++ b/scripts/rabbitmq-service.bat @@ -0,0 +1,188 @@ +@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
+)
+
+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
+)
+
+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=.bak
+
+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
+if "%1" == "start" goto MODIFY_SERVICE
+if "%1" == "stop" goto MODIFY_SERVICE
+if "%1" == "disable" goto MODIFY_SERVICE
+if "%1" == "enable" goto MODIFY_SERVICE
+if "%1" == "list" goto MODIFY_SERVICE
+if "%1" == "remove" 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.
+if "%1" == "" pause
+exit /B
+goto END
+
+
+: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=%~dp0%
+set RABBIT_EBIN=%RABBIT_LIB:\=/%../ebin
+
+set ERLANG_SERVICE_ARGUMENTS= ^
+-pa "%RABBIT_EBIN%" ^
+-boot start_sasl ^
+-s rabbit ^
++W w ^
++A30 ^
+-kernel inet_default_listen_options "[{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 false ^
+-os_mon start_os_sup false ^
+-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% ^
+-debugtype reuse ^
+-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 |