| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | @echo off | 
					
						
							| 
									
										
										
										
											2015-06-24 11:42:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2019-03-12 21:28:13 +08:00
										 |  |  | REM  at https://www.mozilla.org/MPL/ | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2013-07-01 17:49:14 +08:00
										 |  |  | REM  The Initial Developer of the Original Code is GoPivotal, Inc. | 
					
						
							| 
									
										
										
										
											2019-01-14 03:54:12 +08:00
										 |  |  | REM  Copyright (c) 2007-2019 Pivotal Software, Inc.  All rights reserved. | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | REM | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | setlocal | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | rem Preserve values that might contain exclamation marks before | 
					
						
							|  |  |  | rem enabling delayed expansion | 
					
						
							|  |  |  | set TDP0=%~dp0 | 
					
						
							|  |  |  | set STAR=%* | 
					
						
							|  |  |  | setlocal enabledelayedexpansion | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 11:42:49 +08:00
										 |  |  | REM Get default settings with user overrides for (RABBITMQ_)<var_name> | 
					
						
							|  |  |  | REM Non-empty defaults should be set in rabbitmq-env | 
					
						
							| 
									
										
										
										
											2015-10-31 00:20:04 +08:00
										 |  |  | call "!TDP0!\rabbitmq-env.bat" %~n0 | 
					
						
							| 
									
										
										
										
											2013-11-05 23:13:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | if not exist "!ERLANG_HOME!\bin\erl.exe" ( | 
					
						
							|  |  |  |     echo. | 
					
						
							|  |  |  |     echo ****************************** | 
					
						
							| 
									
										
										
										
											2011-09-09 19:11:54 +08:00
										 |  |  |     echo ERLANG_HOME not set correctly. | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  |     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. | 
					
						
							| 
									
										
										
										
											2015-02-26 02:19:16 +08:00
										 |  |  |     exit /B 1 | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-14 18:54:38 +08:00
										 |  |  | REM Disable erl_crash.dump by default for control scripts. | 
					
						
							|  |  |  | if not defined ERL_CRASH_DUMP_SECONDS ( | 
					
						
							|  |  |  |     set ERL_CRASH_DUMP_SECONDS=0 | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-30 05:56:23 +08:00
										 |  |  | "!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 ^
 | 
					
						
							| 
									
										
										
										
											2018-09-28 21:04:41 +08:00
										 |  |  | -extra "%RABBITMQ_HOME%\escript\rabbitmq-plugins" !STAR! | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 22:00:40 +08:00
										 |  |  | if ERRORLEVEL 1 ( | 
					
						
							| 
									
										
										
										
											2019-08-30 21:21:31 +08:00
										 |  |  |     exit /B %ERRORLEVEL% | 
					
						
							| 
									
										
										
										
											2018-10-17 22:00:40 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Move most of shell scripts to Erlang code
A large part of the rabbitmq-server(8) and CLI scripts, both
Bourne-shell and Windows Batch versions, was moved to Erlang code and
the RabbitMQ startup procedure was reorganized to be closer to a regular
Erlang application.
A new application called `rabbitmq_prelaunch` is responsible for:
  1. Querying the environment variables to initialize important
     variables (using the new `rabbit_env` module in rabbitmq-common).
  2. Checking the compatibility with the Erlang/OTP runtime.
  3. Configuring Erlang distribution.
  5. Writing the PID file.
The application is started early (i.e. it is started before `rabbit`).
The `rabbit` application runs the second half of the prelaunch sequence
at the beginning of the application `start()` function. This second
phase is responsible for the following steps:
  1. Preparing the feature flags registry.
  2. Reading and validating the configuration.
  3. Configuring logging.
  4. Running the various cluster checks.
In addition to this prelaunch sequence, the `rabbit` application start
procedure ends with a "postlaunch" sequence which takes care of
starting enabled plugins.
Thanks to this, RabbitMQ can be started with `application:start(rabbit)`
as any other Erlang application. The only caveats are:
  * Mnesia must be stopped at the time `rabbit_prelaunch` is started,
    and must remain stopped when `rabbit` is started, to allow the
    Erlang distribution setup and cluster checks. `rabbit` takes care of
    starting Mnesia.
  * Likewise for Ra, because it relies on the `ra` application
    environment to be configured.
Transitioning from scripts to Erlang code has the following benefits:
  * RabbitMQ start behavior should be identical between Unix and
    Windows. Also, features should be on par now. For instance, RabbitMQ
    now writes a PID file on Windows, like it always did on Unix-based
    systems.
  * The difference between published packages and a development
    environment are greatly reduced. In fact, we removed all the "if
    this is a dev working copy, then ..." blocks.
    As part of that, the `rabbit` application is now treated like its
    plugins: it is packaged as an `.ez` archive and written to the
    `plugins` directory (even though it is not technically a plugin).
    Also in a development copy, the CLI is copied to the top-level
    project. So when testing a plugin for instance, the CLI to use is
    `sbin/rabbitmqctl` in the current directory, not the master copy in
    `rabbit/scripts`.
  * As a consequence of the previous two points, maintaining and testing
    on Windows is now made easy. It should even be possible to setup CI
    on Windows.
  * There are less issues with paths containing non-US-ASCII characters,
    which can happen on Windows because RabbitMQ stores its data in user
    directories by default.
This process brings at least one more benefit: we now have early logging
during this prelaunch phase, which eases diagnostics and debugging.
There are also behavior changes:
  * The new format configuration files used to be converted to an
    Erlang-term-based file by the Cuttlefish CLI. To do that,
    configuration schemas were copied to a temporary directory and the
    generated configuration file was written to RabbitMQ data directory.
    Now, Cuttlefish is used as a library: everything happens in memory.
    No schemas are copied, no generated configuration is written to
    disk.
  * The PID file is removed when the Erlang VM exits.
  * The `rabbit_config` module was trimmed significantly because most of
    the configuration handling is done in `rabbit_prelaunch_conf` now.
  * The RabbitMQ nodename does not appear on the command line, therefore
    it is missing from ps(1) and top(1) output.
  * The `rabbit:start()` function will probably behave differently in
    some ways because it defers everything to the Erlang application
    controller (instead of reimplementing it).
											
										 
											2019-05-15 22:27:51 +08:00
										 |  |  | EXIT /B 0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-09 00:12:56 +08:00
										 |  |  | endlocal | 
					
						
							|  |  |  | endlocal |