diff options
| author | Matthias Radestock <matthias@lshift.net> | 2008-12-18 14:04:59 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2008-12-18 14:04:59 +0000 |
| commit | 9187386298c36c771573759a11546848a2e973ba (patch) | |
| tree | a65539e0e2b9ce3eddbd235e42fc3ea900970216 | |
| parent | 6266723f81a44b5dcd29679c0815623a4a80b276 (diff) | |
| parent | 7c68f363208aa7d7b8cb44c4e4e0d378bf046d29 (diff) | |
| download | rabbitmq-server-git-9187386298c36c771573759a11546848a2e973ba.tar.gz | |
merge default into bug18557
and add license notice on rabbit_limiter
71 files changed, 1680 insertions, 890 deletions
@@ -11,7 +11,9 @@ syntax: regexp ^rabbit.plt$ ^packaging/RPMS/Fedora/(BUILD|RPMS|SOURCES|SPECS|SRPMS)$ -^packaging/debs/Debian/rabbitmq-server_.*\.(dsc|tar\.gz|deb|changes)$ +^packaging/debs/Debian/rabbitmq-server_.*\.(dsc|(diff|tar)\.gz|deb|changes)$ ^packaging/debs/apt-repository/debian$ ^packaging/generic-unix/rabbitmq-server-generic-unix-.*\.tar\.gz$ ^packaging/windows/rabbitmq-server-windows-.*\.zip$ + +^docs/.*\.[15]\.gz$ diff --git a/LICENSE-MPL-RabbitMQ b/LICENSE-MPL-RabbitMQ index 7c2ee3ca0d..2d0a7b1db2 100644 --- a/LICENSE-MPL-RabbitMQ +++ b/LICENSE-MPL-RabbitMQ @@ -446,13 +446,19 @@ EXHIBIT A -Mozilla Public License. The Original Code is RabbitMQ. - The Initial Developers of the Original Code are LShift Ltd., - Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. - - Portions created by LShift Ltd., Cohesive Financial Technologies - LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 - LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit - Technologies Ltd.; + The Initial Developers of the Original Code are LShift Ltd, + Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. + + Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, + Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd + are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial + Technologies LLC, and Rabbit Technologies Ltd. + + Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift + Ltd. Portions created by Cohesive Financial Technologies LLC are + Copyright (C) 2007-2009 Cohesive Financial Technologies + LLC. Portions created by Rabbit Technologies Ltd are Copyright + (C) 2007-2009 Rabbit Technologies Ltd. All Rights Reserved. @@ -1,11 +1,17 @@ -NODENAME=rabbit -RABBIT_ARGS= +RABBITMQ_NODENAME=rabbit +RABBITMQ_SERVER_START_ARGS= +RABBITMQ_MNESIA_DIR=/tmp/rabbitmq-$(RABBITMQ_NODENAME)-mnesia +RABBITMQ_LOG_BASE=/tmp + SOURCE_DIR=src EBIN_DIR=ebin INCLUDE_DIR=include SOURCES=$(wildcard $(SOURCE_DIR)/*.erl) TARGETS=$(EBIN_DIR)/rabbit_framing.beam $(patsubst $(SOURCE_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES)) WEB_URL=http://stage.rabbitmq.com/ +MANPAGES=$(patsubst %.pod, %.gz, $(wildcard docs/*.[0-9].pod)) + +PYTHON=python ifndef USE_SPECS # our type specs rely on features / bug fixes in dialyzer that are @@ -18,9 +24,6 @@ endif #other args: +native +"{hipe,[o3,verbose]}" -Ddebug=true +debug_info +no_strict_record_tests ERLC_OPTS=-I $(INCLUDE_DIR) -o $(EBIN_DIR) -Wall -v +debug_info $(shell [ $(USE_SPECS) = "true" ] && echo "-Duse_specs") -MNESIA_DIR=/tmp/rabbitmq-$(NODENAME)-mnesia -LOG_BASE=/tmp - VERSION=0.0.0 TARBALL_NAME=rabbitmq-server-$(VERSION) TARGET_SRC_DIR=dist/$(TARBALL_NAME) @@ -29,7 +32,7 @@ SIBLING_CODEGEN_DIR=../rabbitmq-codegen/ AMQP_CODEGEN_DIR=$(shell [ -d $(SIBLING_CODEGEN_DIR) ] && echo $(SIBLING_CODEGEN_DIR) || echo codegen) AMQP_SPEC_JSON_PATH=$(AMQP_CODEGEN_DIR)/amqp-0.8.json -ERL_CALL=erl_call -sname $(NODENAME) -e +ERL_CALL=erl_call -sname $(RABBITMQ_NODENAME) -e # for the moment we don't use boot files because they introduce a # dependency on particular versions of OTP applications @@ -40,9 +43,11 @@ $(EBIN_DIR)/%.beam: $(SOURCE_DIR)/%.erl $(INCLUDE_DIR)/rabbit_framing.hrl $(INCL erlc $(ERLC_OPTS) $< # ERLC_EMULATOR="erl -smp" erlc $(ERLC_OPTS) $< -$(INCLUDE_DIR)/rabbit_framing.hrl $(SOURCE_DIR)/rabbit_framing.erl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.py $(AMQP_SPEC_JSON_PATH) - python codegen.py header $(AMQP_SPEC_JSON_PATH) > $(INCLUDE_DIR)/rabbit_framing.hrl - python codegen.py body $(AMQP_SPEC_JSON_PATH) > $(SOURCE_DIR)/rabbit_framing.erl +$(INCLUDE_DIR)/rabbit_framing.hrl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.py $(AMQP_SPEC_JSON_PATH) + $(PYTHON) codegen.py header $(AMQP_SPEC_JSON_PATH) > $@ + +$(SOURCE_DIR)/rabbit_framing.erl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.py $(AMQP_SPEC_JSON_PATH) + $(PYTHON) codegen.py body $(AMQP_SPEC_JSON_PATH) > $@ $(EBIN_DIR)/rabbit.boot $(EBIN_DIR)/rabbit.script: $(EBIN_DIR)/rabbit.app $(EBIN_DIR)/rabbit.rel $(TARGETS) erl -noshell -eval 'systools:make_script("ebin/rabbit", [{path, ["ebin"]}]), halt().' @@ -54,26 +59,39 @@ clean: cleandb rm -f $(EBIN_DIR)/*.beam rm -f $(EBIN_DIR)/rabbit.boot $(EBIN_DIR)/rabbit.script rm -f $(INCLUDE_DIR)/rabbit_framing.hrl $(SOURCE_DIR)/rabbit_framing.erl codegen.pyc + rm -f docs/*.[0-9].gz cleandb: stop-node - erl -mnesia dir '"$(MNESIA_DIR)"' -noshell -eval 'lists:foreach(fun file:delete/1, filelib:wildcard(mnesia:system_info(directory) ++ "/*")), halt().' + erl -mnesia dir '"$(RABBITMQ_MNESIA_DIR)"' -noshell -eval 'lists:foreach(fun file:delete/1, filelib:wildcard(mnesia:system_info(directory) ++ "/*")), halt().' ############ various tasks to interact with RabbitMQ ################### -run: all - NODE_IP_ADDRESS=$(NODE_IP_ADDRESS) NODE_PORT=$(NODE_PORT) NODE_ONLY=true LOG_BASE=$(LOG_BASE) RABBIT_ARGS="$(RABBIT_ARGS) -s rabbit" MNESIA_DIR=$(MNESIA_DIR) ./scripts/rabbitmq-server +BASIC_SCRIPT_ENVIRONMENT_SETTINGS=\ + RABBITMQ_NODE_IP_ADDRESS="$(RABBITMQ_NODE_IP_ADDRESS)" \ + RABBITMQ_NODE_PORT="$(RABBITMQ_NODE_PORT)" \ + RABBITMQ_LOG_BASE="$(RABBITMQ_LOG_BASE)" \ + RABBITMQ_MNESIA_DIR="$(RABBITMQ_MNESIA_DIR)" -check-mnesia-schema: all - NODE_IP_ADDRESS=$(NODE_IP_ADDRESS) NODE_PORT=$(NODE_PORT) LOG_BASE=$(LOG_BASE) MNESIA_DIR=$(MNESIA_DIR) ./scripts/rabbitmq-mnesia-current +run: all + $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \ + RABBITMQ_NODE_ONLY=true \ + RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS) -s rabbit" \ + ./scripts/rabbitmq-server run-node: all - NODE_IP_ADDRESS=$(NODE_IP_ADDRESS) NODE_PORT=$(NODE_PORT) NODE_ONLY=true LOG_BASE=$(LOG_BASE) RABBIT_ARGS="$(RABBIT_ARGS)" MNESIA_DIR=$(MNESIA_DIR) ./scripts/rabbitmq-server + $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \ + RABBITMQ_NODE_ONLY=true \ + RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS)" \ + ./scripts/rabbitmq-server run-tests: all echo "rabbit_tests:all_tests()." | $(ERL_CALL) start-background-node: stop-node - NODE_IP_ADDRESS=$(NODE_IP_ADDRESS) NODE_PORT=$(NODE_PORT) NODE_ONLY=true LOG_BASE=$(LOG_BASE) RABBIT_ARGS="$(RABBIT_ARGS) -detached" MNESIA_DIR=$(MNESIA_DIR) ./scripts/rabbitmq-server ; sleep 1 + $(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \ + RABBITMQ_NODE_ONLY=true \ + RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS) -detached" \ + ./scripts/rabbitmq-server ; sleep 1 start-rabbit-on-node: all echo "rabbit:start()." | $(ERL_CALL) @@ -106,7 +124,7 @@ srcdist: distclean elinks -dump -no-references -no-numbering $(WEB_URL)build-server.html \ >> $(TARGET_SRC_DIR)/BUILD sed -i 's/%%VERSION%%/$(VERSION)/' $(TARGET_SRC_DIR)/ebin/rabbit.app - + cp -r $(AMQP_CODEGEN_DIR)/* $(TARGET_SRC_DIR)/codegen/ cp codegen.py Makefile $(TARGET_SRC_DIR) @@ -119,27 +137,37 @@ srcdist: distclean rm -rf $(TARGET_SRC_DIR) distclean: clean - make -C $(AMQP_CODEGEN_DIR) clean + make -C $(AMQP_CODEGEN_DIR) distclean rm -rf dist - find . -name '*~' -exec rm {} \; + find . -regex '.*\(~\|#\|\.swp\|\.dump\)' -exec rm {} \; + +%.gz: %.pod + pod2man \ + -n `echo $$(basename $*) | sed -e 's/\.[^.]\+//'` \ + -s `echo $$(basename $*) | sed -e 's/.*\.\([^.]\+\)/\1/'` \ + -c "RabbitMQ AMQP Server" \ + -d "" \ + -r "" \ + $< | gzip --best > $@ -install: all +docs_all: $(MANPAGES) + +install: all docs_all @[ -n "$(TARGET_DIR)" ] || (echo "Please set TARGET_DIR."; false) @[ -n "$(SBIN_DIR)" ] || (echo "Please set SBIN_DIR."; false) @[ -n "$(MAN_DIR)" ] || (echo "Please set MAN_DIR."; false) - + mkdir -p $(TARGET_DIR) cp -r ebin include LICENSE LICENSE-MPL-RabbitMQ INSTALL $(TARGET_DIR) chmod 0755 scripts/* mkdir -p $(SBIN_DIR) - mkdir -p $(MAN_DIR)/man1 cp scripts/rabbitmq-server $(SBIN_DIR) cp scripts/rabbitmqctl $(SBIN_DIR) cp scripts/rabbitmq-multi $(SBIN_DIR) - cp scripts/rabbitmq-mnesia-current $(SBIN_DIR) - for manpage in docs/*.pod ; do \ - pod2man -c "RabbitMQ AMQP Server" -d "" -r "" \ - $$manpage | gzip --best > \ - $(MAN_DIR)/man1/`echo $$manpage | sed -e 's:docs/\(.*\)\.pod:\1\.1\.gz:g'`; \ + for section in 1 5; do \ + mkdir -p $(MAN_DIR)/man$$section; \ + for manpage in docs/*.$$section.pod; do \ + cp docs/`basename $$manpage .pod`.gz $(MAN_DIR)/man$$section; \ + done; \ done diff --git a/codegen.py b/codegen.py index 629f2b8c3e..84741ea28d 100644 --- a/codegen.py +++ b/codegen.py @@ -10,13 +10,19 @@ ## ## The Original Code is RabbitMQ. ## -## The Initial Developers of the Original Code are LShift Ltd., -## Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +## The Initial Developers of the Original Code are LShift Ltd, +## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. ## -## Portions created by LShift Ltd., Cohesive Financial Technologies -## LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -## LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -## Technologies Ltd.; +## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +## Technologies LLC, and Rabbit Technologies Ltd. +## +## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +## Ltd. Portions created by Cohesive Financial Technologies LLC are +## Copyright (C) 2007-2009 Cohesive Financial Technologies +## LLC. Portions created by Rabbit Technologies Ltd are Copyright +## (C) 2007-2009 Rabbit Technologies Ltd. ## ## All Rights Reserved. ## diff --git a/docs/rabbitmq-multi.pod b/docs/rabbitmq-multi.1.pod index 65d058337c..82c3911681 100644 --- a/docs/rabbitmq-multi.pod +++ b/docs/rabbitmq-multi.1.pod @@ -44,14 +44,7 @@ rabbitmq-server(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. +The RabbitMQ Team <info@rabbitmq.com> =head1 REFERENCES diff --git a/docs/rabbitmq-server.pod b/docs/rabbitmq-server.1.pod index 1eaf2dfdfb..00210c8b5c 100644 --- a/docs/rabbitmq-server.pod +++ b/docs/rabbitmq-server.1.pod @@ -20,30 +20,30 @@ process or use rabbitmqctl(1). =head1 ENVIRONMENT -B<MNESIA_BASE> +B<RABBITMQ_MNESIA_BASE> Defaults to /var/lib/rabbitmq/mnesia. Set this to the directory where Mnesia database files should be placed. -B<LOG_BASE> +B<RABBITMQ_LOG_BASE> Defaults to /var/log/rabbitmq. Log files generated by the server will be placed in this directory. -B<NODENAME> +B<RABBITMQ_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. + than one node per machine - B<RABBITMQ_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> +B<RABBITMQ_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> +B<RABBITMQ_NODE_PORT> Defaults to 5672. -B<CLUSTER_CONFIG_FILE> +B<RABBITMQ_CLUSTER_CONFIG_FILE> Defaults to /etc/default/rabbitmq_cluster.config. If this file is present it is used by the server to auto-configure a RabbitMQ cluster. @@ -66,14 +66,7 @@ rabbitmq-multi(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. +The RabbitMQ Team <info@rabbitmq.com> =head1 REFERENCES diff --git a/docs/rabbitmq.5.pod b/docs/rabbitmq.5.pod new file mode 100644 index 0000000000..e6972935f5 --- /dev/null +++ b/docs/rabbitmq.5.pod @@ -0,0 +1,60 @@ +=head1 NAME + +/etc/default/rabbitmq - default settings for RabbitMQ AMQP server + +=head1 DESCRIPTION + +/etc/default/rabbitmq contains variable settings that override the +defaults built in to the RabbitMQ startup scripts. + +The file is interpreted by the system shell, and so should consist of +a sequence of shell environment variable definitions. Normal shell +syntax is permitted (since the file is sourced using the shell "." +operator), including line comments starting with "#". + +In order of preference, the startup scripts get their values from the +environment, from /etc/default/rabbitmq, and finally from the built-in +default values. For example, for the B<RABBITMQ_NODENAME> setting, + +B<RABBITMQ_NODENAME> + from the environment is checked first. If it is absent or equal + to the empty string, then + +B<NODENAME> + from /etc/default/rabbitmq is checked next. If it is also absent + or set equal to the empty string, then the default value from the + startup script is used. + +The variable names in /etc/default/rabbitmq are always equal to the +environment variable names, with the B<RABBITMQ_> prefix removed: +B<RABBITMQ_NODE_PORT> from the environment becomes B<NODE_PORT> in the +/etc/default/rabbitmq file, etc. + +=head1 EXAMPLES + +The following is an example of a complete /etc/default/rabbitmq file +that overrides the default Erlang node name from "rabbit" to "hare": + + # I am a complete /etc/default/rabbitmq file. + # Comment lines start with a hash character. + # This is a /bin/sh script file - use ordinary envt var syntax + NODENAME=hare + +=head1 SEE ALSO + +rabbitmq-server(1), rabbitmq-multi(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/docs/rabbitmqctl.pod b/docs/rabbitmqctl.1.pod index b34cbca754..b9edd5847f 100644 --- a/docs/rabbitmqctl.pod +++ b/docs/rabbitmqctl.1.pod @@ -20,13 +20,16 @@ It performs all actions by connecting to one of the broker's nodes. B<-n> I<node> default node is C<rabbit@server>, where server is the local host. - On a host named C<server.example.com>, the node name of the RabbitMQ - Erlang 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. See rabbitmq-server(1) for details of configur- - ing the RabbitMQ broker. + On a host named C<server.example.com>, the node name of the + RabbitMQ Erlang node will usually be rabbit@server (unless + RABBITMQ_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. See rabbitmq-server(1) for + details of configuring the RabbitMQ broker. +B<-q> + quiet output mode is selected with the B<-q> flag. Informational + messages are suppressed when quiet mode is in effect. =head1 COMMANDS @@ -120,6 +123,153 @@ list_user_vhost I<username> list all the virtual hosts to which the user named I<username> has been granted access. +=head2 SERVER STATUS + +list_queues [-p I<vhostpath>] [I<queueinfoitem> ...] + list queue information by virtual host. If no I<queueinfoitem>s + are specified then then name and number of messages is displayed + for each queue. + +=head3 Queue information items + +=over 4 + +name + URL-encoded name of the queue + +durable + whether the queue survives server restarts + +auto_delete + whether the queue will be deleted when no longer used + +arguments + queue arguments + +pid + Erlang process identifier associated with the queue + +messages_ready + number of ready messages + +messages_unacknowledged + number of unacknowledged messages + +messages_uncommitted + number of uncommitted messages + +messages + sum of ready, unacknowledged and uncommitted messages + +acks_uncommitted + number of uncommitted acknowledgements + +consumers + number of consumers + +transactions + number of transactions + +memory + bytes of memory consumed by the Erlang process for the queue, + including stack, heap and internal structures + +=back + +list_exchanges [-p I<vhostpath>] [I<exchangeinfoitem> ...] + list exchange information by virtual host. If no + I<exchangeinfoitem>s are specified then name and type is displayed + for each exchange. + +=head3 Exchange information items + +=over 4 + +name + URL-encoded name of the exchange + +type + exchange type (B<direct>, B<topic> or B<fanout>) + +durable + whether the exchange survives server restarts + +auto_delete + whether the exchange is deleted when no longer used + +arguments + exchange arguments + +=back + +list_bindings [-p I<vhostpath>] + list bindings by virtual host. Each line contains exchange name, + routing key and queue name (all URL encoded) and arguments. + +list_connections [I<connectioninfoitem> ...] + list connection information. If no I<connectioninfoitem>s are + specified then the user, peer address and peer port are displayed. + +=head3 Connection information items + +=over 4 + +pid + Erlang process id associated with the connection + +address + server IP number + +port + server port + +peer_address + peer address + +peer_port + peer port + +state + connection state (B<pre-init>, B<starting>, B<tuning>, B<opening>, + B<running>, B<closing>, B<closed>) + +channels + number of channels using the connection + +user + username associated with the connection + +vhost + URL-encoded virtual host + +timeout + connection timeout + +frame_max + maximum frame size (bytes) + +recv_oct + octets received + +recv_cnt + packets received + +send_oct + octets sent + +send_cnt + packets sent + +send_pend + send queue size + +=back + +The list_queues, list_exchanges and list_bindings commands accept an +optional virtual host parameter for which to display results, defaulting +to I<"/">. The default can be overridden with the B<-p> flag. Result +columns for these commands and list_connections are tab-separated. + =head1 EXAMPLES Create a user named foo with (initial) password bar at the Erlang node @@ -143,14 +293,7 @@ rabbitmq-multi(1), rabbitmq-server(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. +The RabbitMQ Team <info@rabbitmq.com> =head1 REFERENCES diff --git a/ebin/rabbit.app b/ebin/rabbit.app index 0326f461b8..93abd456da 100644 --- a/ebin/rabbit.app +++ b/ebin/rabbit.app @@ -48,4 +48,5 @@ {extra_startup_steps, []}, {default_user, <<"guest">>}, {default_pass, <<"guest">>}, - {default_vhost, <<"/">>}]}]}. + {default_vhost, <<"/">>}, + {memory_alarms, false}]}]}. diff --git a/include/rabbit.hrl b/include/rabbit.hrl index 42bc8fa9c8..d07aeaf845 100644 --- a/include/rabbit.hrl +++ b/include/rabbit.hrl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -66,6 +72,8 @@ -type(erlang_node() :: atom()). -type(socket() :: port()). -type(thunk(T) :: fun(() -> T)). +-type(info_key() :: atom()). +-type(info() :: {info_key(), any()}). %% this is really an abstract type, but dialyzer does not support them -type(guid() :: any()). @@ -133,7 +141,7 @@ %%---------------------------------------------------------------------------- --define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2008 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd."). +-define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd."). -define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/"). -ifdef(debug). diff --git a/include/rabbit_framing_spec.hrl b/include/rabbit_framing_spec.hrl index 130001535a..f45fa6caf4 100644 --- a/include/rabbit_framing_spec.hrl +++ b/include/rabbit_framing_spec.hrl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/packaging/RPMS/Fedora/Makefile b/packaging/RPMS/Fedora/Makefile index 2c028e702b..c05f14a7cb 100644 --- a/packaging/RPMS/Fedora/Makefile +++ b/packaging/RPMS/Fedora/Makefile @@ -1,14 +1,13 @@ -# Read README.txt for instructions - VERSION=0.0.0 SOURCE_TARBALL_DIR=../../../dist TARBALL=$(SOURCE_TARBALL_DIR)/rabbitmq-server-$(VERSION).tar.gz TOP_DIR=$(shell pwd) +#Under debian we do not want to check build dependencies, since that +#only checks build-dependencies using rpms, not debs DEFINES=--define '_topdir $(TOP_DIR)' --define '_tmppath $(TOP_DIR)/tmp' --define 'debian 1' rpms: clean server -#Create proper environment for making rpms prepare: mkdir -p BUILD SOURCES SPECS SRPMS RPMS tmp cp $(TOP_DIR)/$(TARBALL) SOURCES @@ -18,11 +17,11 @@ prepare: cp init.d SOURCES/rabbitmq-server.init cp rabbitmqctl_wrapper SOURCES/rabbitmq-server.wrapper cp rabbitmq-server.logrotate SOURCES/rabbitmq-server.logrotate - cp rabbitmq-server-preserve-db.sh SOURCES server: prepare rpmbuild -ba SPECS/rabbitmq-server.spec $(DEFINES) --target i386 - rpmbuild -ba SPECS/rabbitmq-server.spec $(DEFINES) --target x86_64 + rpmbuild -ba SPECS/rabbitmq-server.spec $(DEFINES) --define '_arch x86_64' \ + --define '_defaultdocdir /usr/share/doc' --target x86_64 clean: rm -rf SOURCES SPECS RPMS SRPMS BUILD tmp diff --git a/packaging/RPMS/Fedora/README.txt b/packaging/RPMS/Fedora/README.txt deleted file mode 100644 index 6f31325970..0000000000 --- a/packaging/RPMS/Fedora/README.txt +++ /dev/null @@ -1,49 +0,0 @@ -Notes on creating rpms for rabbitmq - -Assuming that rpm will be built under $TOP_DIR/rpm, -the main configuration variables would look like: - -%_topdir $TOP_DIR/rpm -%_tmppath $TOP_DIR/rpm/tmp -%_bindir /usr/bin -%_libdir /usr/lib -%_includedir /usr/include -%_mandir /usr/share/man - -Where $TOP_DIR can be any directory (default is $HOME). - -The $TOP_DIR/rpm directory has following structure: - -rpm - +---- BUILD // directory where tarballs are unpacked - +---- SOURCES // where source tarballs are put - +---- SPECS // directory containing specs - +---- SRPMS // rpmbuild puts here srpms - +---- RPMS // rpmbuils puts here rpms - +---- tmp // where rpm packages are built - -Makefile will copy the source tarball from fixed directory -specified by $TARBALL_DIR to SOURCES directory and -similarly specs from $SPEC_DIR to SPECS directory. - -'make rpms' should create rabbitmq-server package. -If there are any errors reported by rpmbuild this is -possibly due to incorrect name of the packages -(if all dependencies are satisifed) - different distros -can have slightly different names. - -rpms and srpms are placed in their respective directories. - -'make prepare' will create the necessary structure. -Change main configuration variables specified in the 'DEFINES' -variable in the Makefile to adjust it to your system. -Note that it will *overwrite* any current rpmmacros -configurations. - -The first thing to do for building rpms is to create you own -source tarball of AMQ. In the spec files two top variables -determine the name of the tarball. Adjust it to you needs. -The final name has to match the *Source* tag in spec's headers. - -For information on how to sign the package see: -http://fedoranews.org/tchung/gpg/ diff --git a/packaging/RPMS/Fedora/rabbitmq-server-preserve-db.sh b/packaging/RPMS/Fedora/rabbitmq-server-preserve-db.sh deleted file mode 100644 index e885b6b80f..0000000000 --- a/packaging/RPMS/Fedora/rabbitmq-server-preserve-db.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -if [ "$1x" = "x" ]; then - echo "You haven't specified the initial location of the RabbitMQ database" - exit 1 -fi - -if [ ! -d "$1" ]; then - echo "The directory containing the RabbitMQ database doesn't exist" - exit 1 -fi - -echo -echo "The RabbitMQ database schema has changed." -echo "If your RabbitMQ database contains important data," -echo "such as user accounts, durable exchanges and queues," -echo "or persistent messages, then we recommend you contact" -echo "support@rabbitmq.com for assistance with the upgrade." -echo "The current RabbitMQ database will be moved to the" -echo "directory: " - -CURRENT_MNESIA_DIR=$1 -DATE=`date +'%d_%m_%Y'` -TMP_OLD_MNESIA_DIR=$CURRENT_MNESIA_DIR.$$.${DATE} -mv "$CURRENT_MNESIA_DIR" "$TMP_OLD_MNESIA_DIR" - -echo "$TMP_OLD_MNESIA_DIR" -echo
\ No newline at end of file diff --git a/packaging/RPMS/Fedora/rabbitmq-server.spec b/packaging/RPMS/Fedora/rabbitmq-server.spec index fbee9ef3d7..13cfb0372e 100644 --- a/packaging/RPMS/Fedora/rabbitmq-server.spec +++ b/packaging/RPMS/Fedora/rabbitmq-server.spec @@ -7,7 +7,6 @@ Source: http://www.rabbitmq.com/releases/rabbitmq-server/v%{version}/%{name}-%{v Source1: rabbitmq-server.init Source2: rabbitmq-server.wrapper Source3: rabbitmq-server.logrotate -Source4: rabbitmq-server-preserve-db.sh URL: http://www.rabbitmq.com/ Vendor: LShift Ltd., Cohesive Financial Technologies LLC., Rabbit Technlogies Ltd. %if 0%{?debian} @@ -64,15 +63,27 @@ mkdir -p %{buildroot}/etc/rc.d/init.d/ #Copy all necessary lib files etc. install -m 0755 %SOURCE1 %{buildroot}/etc/rc.d/init.d/rabbitmq-server chmod 0755 %{buildroot}/etc/rc.d/init.d/rabbitmq-server +%ifarch x86_64 + sed -i 's/\/usr\/lib\//\/usr\/lib64\//' %{buildroot}/etc/rc.d/init.d/rabbitmq-server +%endif mkdir -p %{buildroot}%{_sbindir} install -m 0755 %SOURCE2 %{buildroot}%{_sbindir}/rabbitmqctl +%ifarch x86_64 + sed -i 's/\/usr\/lib\//\/usr\/lib64\//' %{buildroot}%{_sbindir}/rabbitmqctl +%endif mkdir -p %{buildroot}/etc/logrotate.d -install %SOURCE3 %{buildroot}/etc/logrotate.d/rabbitmq-server +install -m 0644 %SOURCE3 %{buildroot}/etc/logrotate.d/rabbitmq-server rm %{_maindir}/LICENSE %{_maindir}/LICENSE-MPL-RabbitMQ %{_maindir}/INSTALL +#Build the list of files +rm -f %{_builddir}/filelist.%{name}.rpm +echo '%defattr(-,root,root, -)' >> %{_builddir}/filelist.%{name}.rpm +(cd %{buildroot}; find . ! -regex '\./etc.*' \ + -type f | sed -e 's/^\.//' >> %{_builddir}/filelist.%{name}.rpm) + %post # create rabbitmq group if ! getent group rabbitmq >/dev/null; then @@ -82,17 +93,12 @@ fi # create rabbitmq user if ! getent passwd rabbitmq >/dev/null; then useradd -r -g rabbitmq --home /var/lib/rabbitmq rabbitmq - usermod -c "Rabbit AMQP Messaging Server" rabbitmq + usermod -c "RabbitMQ messaging server" rabbitmq fi chown -R rabbitmq:rabbitmq /var/lib/rabbitmq chown -R rabbitmq:rabbitmq /var/log/rabbitmq -su rabbitmq -s /bin/sh -c %{_rabbitbindir}/rabbitmq-mnesia-current -if [ $? = 1 ]; then - /bin/sh %SOURCE4 /var/lib/rabbitmq/mnesia -fi - /sbin/chkconfig --add %{name} /sbin/service rabbitmq-server start @@ -106,14 +112,8 @@ if [ $1 = 0 ]; then # Leave rabbitmq user and group fi -%files +%files -f ../filelist.%{name}.rpm %defattr(-,root,root,-) -%{_erllibdir}/rabbitmq_server-%{version}/ -%{_rabbitbindir}/ -%{_mandir}/man1/rabbitmq-multi.1.gz -%{_mandir}/man1/rabbitmq-server.1.gz -%{_mandir}/man1/rabbitmqctl.1.gz -%{_sbindir}/rabbitmqctl %dir /var/lib/rabbitmq %dir /var/log/rabbitmq /etc/rc.d/init.d/rabbitmq-server @@ -124,6 +124,9 @@ fi rm -rf %{buildroot} %changelog +* Wed Dec 17 2008 Matthias Radestock <matthias@lshift.net> 1.5.0-1 +- New upstream release + * Thu Jul 24 2008 Tony Garnock-Jones <tonyg@lshift.net> 1.4.0-1 - New upstream release diff --git a/packaging/debs/Debian/debian/changelog b/packaging/debs/Debian/debian/changelog index 07f5a8dd41..e8be8d8d8c 100644 --- a/packaging/debs/Debian/debian/changelog +++ b/packaging/debs/Debian/debian/changelog @@ -1,3 +1,9 @@ +rabbitmq-server (1.5.0-1) testing; urgency=low + + * New Upstream Release + + -- Matthias Radestock <matthias@lshift.net> Wed, 17 Dec 2008 18:23:47 +0000 + rabbitmq-server (1.4.0-1) testing; urgency=low * New Upstream Release diff --git a/packaging/debs/Debian/debian/control b/packaging/debs/Debian/debian/control index f6761713dd..b2b3ab0236 100644 --- a/packaging/debs/Debian/debian/control +++ b/packaging/debs/Debian/debian/control @@ -3,11 +3,11 @@ Section: net Priority: extra Maintainer: Tony Garnock-Jones <tonyg@rabbitmq.com> Build-Depends: cdbs, debhelper (>= 5), erlang-nox, erlang-dev, python-simplejson -Standards-Version: 3.7.2 +Standards-Version: 3.8.0 Package: rabbitmq-server Architecture: all -Depends: erlang-nox, adduser, logrotate, debconf +Depends: erlang-nox, adduser, logrotate, ${misc:Depends} Description: An AMQP server written in Erlang RabbitMQ is an implementation of AMQP, the emerging standard for high performance enterprise messaging. The RabbitMQ server is a robust and diff --git a/packaging/debs/Debian/debian/copyright b/packaging/debs/Debian/debian/copyright index 9f9f8672bc..f9a2b6515a 100644 --- a/packaging/debs/Debian/debian/copyright +++ b/packaging/debs/Debian/debian/copyright @@ -5,7 +5,7 @@ It was downloaded from http://www.rabbitmq.com/ Upstream Author: The RabbitMQ team <info@rabbitmq.com> -Copyright: 2006-2008 Rabbit Technologies Ltd. +Copyright: 2006-2009 Rabbit Technologies Ltd. License: The RabbitMQ server is licensed under the MPL. @@ -461,13 +461,19 @@ EXHIBIT A -Mozilla Public License. The Original Code is RabbitMQ. - The Initial Developers of the Original Code are LShift Ltd., - Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. + The Initial Developers of the Original Code are LShift Ltd, + Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. - Portions created by LShift Ltd., Cohesive Financial Technologies - LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 - LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit - Technologies Ltd.; + Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, + Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd + are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial + Technologies LLC, and Rabbit Technologies Ltd. + + Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift + Ltd. Portions created by Cohesive Financial Technologies LLC are + Copyright (C) 2007-2009 Cohesive Financial Technologies + LLC. Portions created by Rabbit Technologies Ltd are Copyright + (C) 2007-2009 Rabbit Technologies Ltd. All Rights Reserved. @@ -485,7 +491,7 @@ EXHIBIT A -Mozilla Public License. If you have any questions regarding licensing, please contact us at info@rabbitmq.com. -The Debian packaging is (C) 2007-2008, Rabbit Technologies Ltd. <info@rabbitmq.com> +The Debian packaging is (C) 2007-2009, Rabbit Technologies Ltd. <info@rabbitmq.com> and is licensed under the MPL 1.1, see above. diff --git a/packaging/debs/Debian/debian/postinst b/packaging/debs/Debian/debian/postinst index 13d8552f3d..495b8331f0 100644 --- a/packaging/debs/Debian/debian/postinst +++ b/packaging/debs/Debian/debian/postinst @@ -26,7 +26,7 @@ fi # create rabbitmq user if ! getent passwd rabbitmq >/dev/null; then adduser --system --ingroup rabbitmq --home /var/lib/rabbitmq --no-create-home rabbitmq - usermod -c "Rabbit AMQP Messaging Server" rabbitmq + usermod -c "RabbitMQ messaging server" rabbitmq fi chown -R rabbitmq:rabbitmq /var/lib/rabbitmq @@ -34,28 +34,6 @@ chown -R rabbitmq:rabbitmq /var/log/rabbitmq case "$1" in configure) - . /usr/share/debconf/confmodule - - if ! su rabbitmq -s /bin/sh -c /usr/lib/rabbitmq/bin/rabbitmq-mnesia-current ; then - db_beginblock - db_input high rabbitmq-server/mnesia-dir-note || true - db_input high rabbitmq-server/do-what-with-mnesia-dir || true - db_endblock - db_go - - db_get rabbitmq-server/do-what-with-mnesia-dir - if [ "$RET" = "Delete it" ]; then - rm -r /var/lib/rabbitmq/mnesia/ - elif [ "$RET" = "Move it elsewhere" ]; then - db_input high rabbitmq-server/move-mnesia-dir-where || true - db_go - - db_get rabbitmq-server/move-mnesia-dir-where - - mkdir -p "`dirname $RET`" - mv /var/lib/rabbitmq/mnesia "$RET" - fi - fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/packaging/debs/Debian/debian/preinst.ex b/packaging/debs/Debian/debian/preinst.ex deleted file mode 100644 index 044ce6ba02..0000000000 --- a/packaging/debs/Debian/debian/preinst.ex +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# preinst script for rabbitmq -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * <new-preinst> `install' -# * <new-preinst> `install' <old-version> -# * <new-preinst> `upgrade' <old-version> -# * <old-preinst> `abort-upgrade' <new-version> -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - install|upgrade) - ;; - - abort-upgrade) - ;; - - *) - echo "preinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 - - diff --git a/packaging/debs/Debian/debian/prerm.ex b/packaging/debs/Debian/debian/prerm.ex deleted file mode 100644 index c74dc32555..0000000000 --- a/packaging/debs/Debian/debian/prerm.ex +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# prerm script for rabbitmq -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * <prerm> `remove' -# * <old-prerm> `upgrade' <new-version> -# * <new-prerm> `failed-upgrade' <old-version> -# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version> -# * <deconfigured's-prerm> `deconfigure' `in-favour' -# <package-being-installed> <version> `removing' -# <conflicting-package> <version> -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - remove|upgrade|deconfigure) - ;; - - failed-upgrade) - ;; - - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 - - diff --git a/packaging/debs/Debian/debian/rabbitmqctl_wrapper b/packaging/debs/Debian/debian/rabbitmqctl_wrapper index 774731fc9e..d53a6ca9c6 100644 --- a/packaging/debs/Debian/debian/rabbitmqctl_wrapper +++ b/packaging/debs/Debian/debian/rabbitmqctl_wrapper @@ -11,7 +11,7 @@ done cd / -if [ ${UID} = 0 ] ; then +if [ `id -u` = 0 ] ; then su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/rabbitmqctl ${CMDLINE}" else /usr/lib/rabbitmq/bin/rabbitmqctl diff --git a/packaging/debs/Debian/debian/rules b/packaging/debs/Debian/debian/rules index fa4cb855cc..908ec4817f 100644 --- a/packaging/debs/Debian/debian/rules +++ b/packaging/debs/Debian/debian/rules @@ -7,6 +7,7 @@ RABBIT_LIB=$(DEB_DESTDIR)usr/lib/erlang/lib/rabbitmq_server-$(DEB_UPSTREAM_VERSI RABBIT_BIN=$(DEB_DESTDIR)usr/lib/rabbitmq/bin/ DEB_MAKE_INSTALL_TARGET := install TARGET_DIR=$(RABBIT_LIB) SBIN_DIR=$(RABBIT_BIN) MAN_DIR=$(DEB_DESTDIR)usr/share/man/ +DEB_MAKE_CLEAN_TARGET:= distclean DOCDIR=$(DEB_DESTDIR)usr/share/doc/rabbitmq-server/ @@ -14,5 +15,4 @@ install/rabbitmq-server:: mkdir -p $(DOCDIR) rm $(RABBIT_LIB)LICENSE* cp debian/rabbitmqctl_wrapper $(DEB_DESTDIR)usr/sbin/rabbitmqctl - cp debian/rabbitmq-server.logrotate $(DEB_DESTDIR)etc/logrotate.d/rabbitmq-server chmod a+x $(DEB_DESTDIR)usr/sbin/rabbitmqctl diff --git a/packaging/debs/Debian/debian/templates b/packaging/debs/Debian/debian/templates deleted file mode 100644 index 89f5754bd7..0000000000 --- a/packaging/debs/Debian/debian/templates +++ /dev/null @@ -1,16 +0,0 @@ -Template: rabbitmq-server/mnesia-dir-note -Type: note -Description: Schema changed - The RabbitMQ database schema has changed. If your RabbitMQ database contains important data, such as user accounts, durable exchanges and queues, or persistent messages, then we recommend you contact support@rabbitmq.com for assistance with the upgrade. If you want to experiment with the new version in the meantime, simply move the database directory to a safe place. In all other cases just remove the directory. - - -Template: rabbitmq-server/do-what-with-mnesia-dir -Type: select -Choices: Delete it, Move it elsewhere, Keep it in place (WILL BREAK) -Default: Delete it -Description: What do you want to do with the RabbitMQ database directory? - -Template: rabbitmq-server/move-mnesia-dir-where -Type: string -Default: /var/lib/rabbitmq/mnesia-old/ -Description: Where do you want to move the RabbitMQ database directory? diff --git a/packaging/windows/rabbitmq-service.pod b/packaging/windows/rabbitmq-service.pod index 6a97c435d9..7c4d3ef210 100644 --- a/packaging/windows/rabbitmq-service.pod +++ b/packaging/windows/rabbitmq-service.pod @@ -63,7 +63,7 @@ type to B<Automatic> using the service control panel. =head1 ENVIRONMENT -=head2 SERVICENAME +=head2 RABBITMQ_SERVICENAME Defaults to RabbitMQ. This is the location of log and database directories. @@ -73,21 +73,20 @@ This is the location of log and database directories. Defaults to the application data directory of the current user. This is the location of log and database directories. -=head2 NODENAME +=head2 RABBITMQ_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 +Defaults to "rabbit". This can be useful if you want to run more than +one node per machine - B<RABBITMQ_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. +machine guide at +L<http://www.rabbitmq.com/clustering.html#single-machine> for details. -=head2 NODE_IP_ADDRESS +=head2 RABBITMQ_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 +=head2 RABBITMQ_NODE_PORT Defaults to 5672. @@ -102,7 +101,7 @@ 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 +=head2 RABBITMQ_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 @@ -110,11 +109,12 @@ 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. +If B<RABBITMQ_CONSOLE_LOG> is set to B<new> then a new file will be +created each time the service starts. If B<RABBITMQ_CONSOLE_LOG> is +set to B<reuse> then the file will be overwritten each time the +service starts. The default behaviour when B<RABBITMQ_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 @@ -124,14 +124,7 @@ Start a previously-installed RabbitMQ AMQP service: =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. +The RabbitMQ Team <info@rabbitmq.com> =head1 REFERENCES diff --git a/scripts/rabbitmq-mnesia-current b/scripts/rabbitmq-mnesia-current deleted file mode 100755 index 45f1a84595..0000000000 --- a/scripts/rabbitmq-mnesia-current +++ /dev/null @@ -1,50 +0,0 @@ -#!/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 -## http://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 Developers of the Original Code are LShift Ltd., -## Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. -## -## Portions created by LShift Ltd., Cohesive Financial Technologies -## LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -## LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -## Technologies Ltd.; -## -## All Rights Reserved. -## -## Contributor(s): ______________________________________. -## - -[ "x" = "x$NODENAME" ] && NODENAME=rabbit -[ "x" = "x$NODE_IP_ADDRESS" ] && NODE_IP_ADDRESS=0.0.0.0 -[ "x" = "x$NODE_PORT" ] && NODE_PORT=5672 - -CLUSTER_CONFIG_FILE=/etc/default/rabbitmq_cluster.config - -[ "x" = "x$LOG_BASE" ] && LOG_BASE=/var/log/rabbitmq -[ "x" = "x$MNESIA_BASE" ] && MNESIA_BASE=/var/lib/rabbitmq/mnesia -[ "x" = "x$MNESIA_DIR" ] && MNESIA_DIR=${MNESIA_BASE}/${NODENAME} - -if [ -f "$CLUSTER_CONFIG_FILE" ]; then - CLUSTER_CONFIG="-rabbit cluster_config \"$CLUSTER_CONFIG_FILE\"" -else - CLUSTER_CONFIG="" -fi - -exec erl \ - -pa "`dirname $0`/../ebin" \ - -noshell \ - -sname ${NODENAME} \ - -eval 'halt(case rabbit_mnesia:schema_current() of true -> 0; false -> 1 end).' \ - -mnesia dir "\"${MNESIA_DIR}\"" \ - -kernel error_logger '{file,"'/dev/null'"}' \ - ${CLUSTER_CONFIG} diff --git a/scripts/rabbitmq-multi b/scripts/rabbitmq-multi index 5e4f4b3862..84985e900f 100755 --- a/scripts/rabbitmq-multi +++ b/scripts/rabbitmq-multi @@ -11,37 +11,55 @@ ## ## The Original Code is RabbitMQ. ## -## The Initial Developers of the Original Code are LShift Ltd., -## Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +## The Initial Developers of the Original Code are LShift Ltd, +## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. ## -## Portions created by LShift Ltd., Cohesive Financial Technologies -## LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -## LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -## Technologies Ltd.; +## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +## Technologies LLC, and Rabbit Technologies Ltd. +## +## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +## Ltd. Portions created by Cohesive Financial Technologies LLC are +## Copyright (C) 2007-2009 Cohesive Financial Technologies +## LLC. Portions created by Rabbit Technologies Ltd are Copyright +## (C) 2007-2009 Rabbit Technologies Ltd. ## ## All Rights Reserved. ## ## Contributor(s): ______________________________________. ## -[ "x" = "x$NODENAME" ] && NODENAME=rabbit -[ "x" = "x$NODE_IP_ADDRESS" ] && NODE_IP_ADDRESS=0.0.0.0 -[ "x" = "x$NODE_PORT" ] && NODE_PORT=5672 - -ERL_ARGS= -SCRIPT_HOME=$(dirname $0) +[ -f /etc/default/rabbitmq ] && . /etc/default/rabbitmq -[ "x" = "x$PIDS_FILE" ] && PIDS_FILE=/var/lib/rabbitmq/pids +[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME} +[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=rabbit +[ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS} +[ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=0.0.0.0 +[ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${NODE_PORT} +[ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=5672 +[ "x" = "x$RABBITMQ_SCRIPT_HOME" ] && RABBITMQ_SCRIPT_HOME=${SCRIPT_HOME} +[ "x" = "x$RABBITMQ_SCRIPT_HOME" ] && RABBITMQ_SCRIPT_HOME=$(dirname $0) +[ "x" = "x$RABBITMQ_PIDS_FILE" ] && RABBITMQ_PIDS_FILE=${PIDS_FILE} +[ "x" = "x$RABBITMQ_PIDS_FILE" ] && RABBITMQ_PIDS_FILE=/var/lib/rabbitmq/pids +[ "x" = "x$RABBITMQ_MULTI_ERL_ARGS" ] && RABBITMQ_MULTI_ERL_ARGS=${MULTI_ERL_ARGS} +[ "x" = "x$RABBITMQ_MULTI_ERL_ARGS" ] && RABBITMQ_MULTI_ERL_ARGS= +[ "x" = "x$RABBITMQ_MULTI_START_ARGS" ] && RABBITMQ_MULTI_START_ARGS=${MULTI_START_ARGS} +[ "x" = "x$RABBITMQ_MULTI_START_ARGS" ] && RABBITMQ_MULTI_START_ARGS= -export NODENAME NODE_IP_ADDRESS NODE_PORT SCRIPT_HOME PIDS_FILE +export \ + RABBITMQ_NODENAME \ + RABBITMQ_NODE_IP_ADDRESS \ + RABBITMQ_NODE_PORT \ + RABBITMQ_SCRIPT_HOME \ + RABBITMQ_PIDS_FILE exec erl \ -pa "`dirname $0`/../ebin" \ -noinput \ -hidden \ - ${ERL_ARGS} \ + ${RABBITMQ_MULTI_ERL_ARGS} \ -sname rabbitmq_multi$$ \ -s rabbit_multi \ - ${START_ARGS} \ + ${RABBITMQ_MULTI_START_ARGS} \ -extra "$@" - diff --git a/scripts/rabbitmq-multi.bat b/scripts/rabbitmq-multi.bat index 819c99af5c..30f33a5a26 100644..100755 --- a/scripts/rabbitmq-multi.bat +++ b/scripts/rabbitmq-multi.bat @@ -11,13 +11,19 @@ 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 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 Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+REM Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+REM are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+REM Technologies LLC, and Rabbit Technologies Ltd.
+REM
+REM Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+REM Ltd. Portions created by Cohesive Financial Technologies LLC are
+REM Copyright (C) 2007-2009 Cohesive Financial Technologies
+REM LLC. Portions created by Rabbit Technologies Ltd are Copyright
+REM (C) 2007-2009 Rabbit Technologies Ltd.
REM
REM All Rights Reserved.
REM
@@ -28,20 +34,20 @@ if "%RABBITMQ_BASE%"=="" ( set RABBITMQ_BASE=%APPDATA%\RabbitMQ
)
-if "%NODENAME%"=="" (
- set NODENAME=rabbit
+if "%RABBITMQ_NODENAME%"=="" (
+ set RABBITMQ_NODENAME=rabbit
)
-if "%NODE_IP_ADDRESS%"=="" (
- set NODE_IP_ADDRESS=0.0.0.0
+if "%RABBITMQ_NODE_IP_ADDRESS%"=="" (
+ set RABBITMQ_NODE_IP_ADDRESS=0.0.0.0
)
-if "%NODE_PORT%"=="" (
- set NODE_PORT=5672
+if "%RABBITMQ_NODE_PORT%"=="" (
+ set RABBITMQ_NODE_PORT=5672
)
-set PIDS_FILE=%RABBITMQ_BASE%\rabbitmq.pids
-set SCRIPT_HOME=%~dp0%
+set RABBITMQ_PIDS_FILE=%RABBITMQ_BASE%\rabbitmq.pids
+set RABBITMQ_SCRIPT_HOME=%~dp0%
if "%ERLANG_HOME%"=="" (
set ERLANG_HOME=%~dp0%..\..\..
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server index 1ce5458e53..bb65d64dd0 100755 --- a/scripts/rabbitmq-server +++ b/scripts/rabbitmq-server @@ -11,67 +11,86 @@ ## ## The Original Code is RabbitMQ. ## -## The Initial Developers of the Original Code are LShift Ltd., -## Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +## The Initial Developers of the Original Code are LShift Ltd, +## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. ## -## Portions created by LShift Ltd., Cohesive Financial Technologies -## LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -## LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -## Technologies Ltd.; +## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +## Technologies LLC, and Rabbit Technologies Ltd. +## +## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +## Ltd. Portions created by Cohesive Financial Technologies LLC are +## Copyright (C) 2007-2009 Cohesive Financial Technologies +## LLC. Portions created by Rabbit Technologies Ltd are Copyright +## (C) 2007-2009 Rabbit Technologies Ltd. ## ## All Rights Reserved. ## ## Contributor(s): ______________________________________. ## -[ "x" = "x$NODENAME" ] && NODENAME=rabbit -[ "x" = "x$NODE_IP_ADDRESS" ] && NODE_IP_ADDRESS=0.0.0.0 -[ "x" = "x$NODE_PORT" ] && NODE_PORT=5672 +[ -f /etc/default/rabbitmq ] && . /etc/default/rabbitmq -ERL_ARGS="+K true +A30 \ +[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=${NODENAME} +[ "x" = "x$RABBITMQ_NODENAME" ] && RABBITMQ_NODENAME=rabbit +[ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=${NODE_IP_ADDRESS} +[ "x" = "x$RABBITMQ_NODE_IP_ADDRESS" ] && RABBITMQ_NODE_IP_ADDRESS=0.0.0.0 +[ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=${NODE_PORT} +[ "x" = "x$RABBITMQ_NODE_PORT" ] && RABBITMQ_NODE_PORT=5672 +[ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_ERL_ARGS=${SERVER_ERL_ARGS} +[ "x" = "x$RABBITMQ_SERVER_ERL_ARGS" ] && RABBITMQ_ERL_ARGS="+K true +A30 \ -kernel inet_default_listen_options [{nodelay,true},{sndbuf,16384},{recbuf,4096}] \ -kernel inet_default_connect_options [{nodelay,true}]" - -CLUSTER_CONFIG_FILE=/etc/default/rabbitmq_cluster.config - -[ "x" = "x$LOG_BASE" ] && LOG_BASE=/var/log/rabbitmq -[ "x" = "x$MNESIA_BASE" ] && MNESIA_BASE=/var/lib/rabbitmq/mnesia -[ "x" = "x$MNESIA_DIR" ] && MNESIA_DIR=${MNESIA_BASE}/${NODENAME} -[ "x" = "x$NODE_ONLY" ] && START_RABBIT='-noinput -s rabbit' +[ "x" = "x$RABBITMQ_CLUSTER_CONFIG_FILE" ] && RABBITMQ_CLUSTER_CONFIG_FILE=${CLUSTER_CONFIG_FILE} +[ "x" = "x$RABBITMQ_CLUSTER_CONFIG_FILE" ] && RABBITMQ_CLUSTER_CONFIG_FILE=/etc/default/rabbitmq_cluster.config +[ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=${LOG_BASE} +[ "x" = "x$RABBITMQ_LOG_BASE" ] && RABBITMQ_LOG_BASE=/var/log/rabbitmq +[ "x" = "x$RABBITMQ_MNESIA_BASE" ] && RABBITMQ_MNESIA_BASE=${MNESIA_BASE} +[ "x" = "x$RABBITMQ_MNESIA_BASE" ] && RABBITMQ_MNESIA_BASE=/var/lib/rabbitmq/mnesia +[ "x" = "x$RABBITMQ_MNESIA_DIR" ] && RABBITMQ_MNESIA_DIR=${MNESIA_DIR} +[ "x" = "x$RABBITMQ_MNESIA_DIR" ] && RABBITMQ_MNESIA_DIR=${RABBITMQ_MNESIA_BASE}/${RABBITMQ_NODENAME} +[ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS=${SERVER_START_ARGS} +[ "x" = "x$RABBITMQ_SERVER_START_ARGS" ] && RABBITMQ_SERVER_START_ARGS= ## Log rotation -LOGS="${LOG_BASE}/${NODENAME}.log" -SASL_LOGS="${LOG_BASE}/${NODENAME}-sasl.log" -BACKUP_EXTENSION=".1" +[ "x" = "x$RABBITMQ_LOGS" ] && RABBITMQ_LOGS=${LOGS} +[ "x" = "x$RABBITMQ_LOGS" ] && RABBITMQ_LOGS="${RABBITMQ_LOG_BASE}/${RABBITMQ_NODENAME}.log" +[ "x" = "x$RABBITMQ_SASL_LOGS" ] && RABBITMQ_SASL_LOGS=${SASL_LOGS} +[ "x" = "x$RABBITMQ_SASL_LOGS" ] && RABBITMQ_SASL_LOGS="${RABBITMQ_LOG_BASE}/${RABBITMQ_NODENAME}-sasl.log" +[ "x" = "x$RABBITMQ_BACKUP_EXTENSION" ] && RABBITMQ_BACKUP_EXTENSION=${BACKUP_EXTENSION} +[ "x" = "x$RABBITMQ_BACKUP_EXTENSION" ] && RABBITMQ_BACKUP_EXTENSION=".1" -[ -f "${LOGS}" ] && cat "${LOGS}" >> "${LOGS}${BACKUP_EXTENSION}" -[ -f "${SASL_LOGS}" ] && cat "${SASL_LOGS}" >> "${SASL_LOGS}${BACKUP_EXTENSION}" +[ -f "${RABBITMQ_LOGS}" ] && cat "${RABBITMQ_LOGS}" >> "${RABBITMQ_LOGS}${RABBITMQ_BACKUP_EXTENSION}" +[ -f "${RABBITMQ_SASL_LOGS}" ] && cat "${RABBITMQ_SASL_LOGS}" >> "${RABBITMQ_SASL_LOGS}${RABBITMQ_BACKUP_EXTENSION}" -if [ -f "$CLUSTER_CONFIG_FILE" ]; then - CLUSTER_CONFIG="-rabbit cluster_config \"$CLUSTER_CONFIG_FILE\"" +if [ -f "$RABBITMQ_CLUSTER_CONFIG_FILE" ]; then + RABBITMQ_CLUSTER_CONFIG_OPTION="-rabbit cluster_config \"$RABBITMQ_CLUSTER_CONFIG_FILE\"" else - CLUSTER_CONFIG="" + RABBITMQ_CLUSTER_CONFIG_OPTION="" fi +RABBITMQ_START_RABBIT= +[ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT='-noinput -s rabbit' + exec erl \ -pa "`dirname $0`/../ebin" \ - ${START_RABBIT} \ - -sname ${NODENAME} \ + ${RABBITMQ_START_RABBIT} \ + -sname ${RABBITMQ_NODENAME} \ -boot start_sasl \ +W w \ - ${ERL_ARGS} \ - -rabbit tcp_listeners '[{"'${NODE_IP_ADDRESS}'", '${NODE_PORT}'}]' \ + ${RABBITMQ_SERVER_ERL_ARGS} \ + -rabbit tcp_listeners '[{"'${RABBITMQ_NODE_IP_ADDRESS}'", '${RABBITMQ_NODE_PORT}'}]' \ -sasl errlog_type error \ - -kernel error_logger '{file,"'${LOGS}'"}' \ - -sasl sasl_error_logger '{file,"'${SASL_LOGS}'"}' \ + -kernel error_logger '{file,"'${RABBITMQ_LOGS}'"}' \ + -sasl sasl_error_logger '{file,"'${RABBITMQ_SASL_LOGS}'"}' \ -os_mon start_cpu_sup true \ -os_mon start_disksup false \ -os_mon start_memsup false \ -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} \ + -mnesia dir "\"${RABBITMQ_MNESIA_DIR}\"" \ + ${RABBITMQ_CLUSTER_CONFIG_OPTION} \ + ${RABBITMQ_SERVER_START_ARGS} \ "$@" - diff --git a/scripts/rabbitmq-server.bat b/scripts/rabbitmq-server.bat index b21c2739bf..5b20ef2010 100755 --- a/scripts/rabbitmq-server.bat +++ b/scripts/rabbitmq-server.bat @@ -11,13 +11,19 @@ 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 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 Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+REM Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+REM are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+REM Technologies LLC, and Rabbit Technologies Ltd.
+REM
+REM Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+REM Ltd. Portions created by Cohesive Financial Technologies LLC are
+REM Copyright (C) 2007-2009 Cohesive Financial Technologies
+REM LLC. Portions created by Rabbit Technologies Ltd are Copyright
+REM (C) 2007-2009 Rabbit Technologies Ltd.
REM
REM All Rights Reserved.
REM
@@ -28,16 +34,16 @@ if "%RABBITMQ_BASE%"=="" ( set RABBITMQ_BASE=%APPDATA%\RabbitMQ
)
-if "%NODENAME%"=="" (
- set NODENAME=rabbit
+if "%RABBITMQ_NODENAME%"=="" (
+ set RABBITMQ_NODENAME=rabbit
)
-if "%NODE_IP_ADDRESS%"=="" (
- set NODE_IP_ADDRESS=0.0.0.0
+if "%RABBITMQ_NODE_IP_ADDRESS%"=="" (
+ set RABBITMQ_NODE_IP_ADDRESS=0.0.0.0
)
-if "%NODE_PORT%"=="" (
- set NODE_PORT=5672
+if "%RABBITMQ_NODE_PORT%"=="" (
+ set RABBITMQ_NODE_PORT=5672
)
if "%ERLANG_HOME%"=="" (
@@ -58,8 +64,12 @@ if not exist "%ERLANG_HOME%\bin\erl.exe" ( set RABBITMQ_BASE_UNIX=%RABBITMQ_BASE:\=/%
-set MNESIA_BASE=%RABBITMQ_BASE_UNIX%/db
-set LOG_BASE=%RABBITMQ_BASE_UNIX%/log
+if "%RABBITMQ_MNESIA_BASE%"=="" (
+ set RABBITMQ_MNESIA_BASE=%RABBITMQ_BASE_UNIX%/db
+)
+if "%RABBITMQ_LOG_BASE%"=="" (
+ set RABBITMQ_LOG_BASE=%RABBITMQ_BASE_UNIX%/log
+)
rem We save the previous logs in their respective backup
@@ -67,11 +77,11 @@ rem Log management (rotation, filtering based of size...) is left as an exercice set BACKUP_EXTENSION=.1
-set LOGS="%RABBITMQ_BASE%\log\%NODENAME%.log"
-set SASL_LOGS="%RABBITMQ_BASE%\log\%NODENAME%-sasl.log"
+set LOGS="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%.log"
+set SASL_LOGS="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%-sasl.log"
-set LOGS_BACKUP="%RABBITMQ_BASE%\log\%NODENAME%.log%BACKUP_EXTENSION%"
-set SASL_LOGS_BAKCUP="%RABBITMQ_BASE%\log\%NODENAME%-sasl.log%BACKUP_EXTENSION%"
+set LOGS_BACKUP="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%.log%BACKUP_EXTENSION%"
+set SASL_LOGS_BAKCUP="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%-sasl.log%BACKUP_EXTENSION%"
if exist %LOGS% (
type %LOGS% >> %LOGS_BACKUP%
@@ -83,36 +93,39 @@ if exist %SASL_LOGS% ( rem End of log management
-set CLUSTER_CONFIG_FILE=%RABBITMQ_BASE%\rabbitmq_cluster.config
+if "%RABBITMQ_CLUSTER_CONFIG_FILE%"=="" (
+ set RABBITMQ_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:\=/%"\"
+if not exist "%RABBITMQ_CLUSTER_CONFIG_FILE%" GOTO L1
+set CLUSTER_CONFIG=-rabbit cluster_config \""%RABBITMQ_CLUSTER_CONFIG_FILE:\=/%"\"
:L1
-set MNESIA_DIR=%MNESIA_BASE%/%NODENAME%-mnesia
+if "%RABBITMQ_MNESIA_DIR%"=="" (
+ set RABBITMQ_MNESIA_DIR=%RABBITMQ_MNESIA_BASE%/%RABBITMQ_NODENAME%-mnesia
+)
"%ERLANG_HOME%\bin\erl.exe" ^
-pa "%~dp0..\ebin" ^
-noinput ^
-boot start_sasl ^
--sname %NODENAME% ^
+-sname %RABBITMQ_NODENAME% ^
-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"\"} ^
+-rabbit tcp_listeners "[{\"%RABBITMQ_NODE_IP_ADDRESS%\", %RABBITMQ_NODE_PORT%}]" ^
+-kernel error_logger {file,\""%RABBITMQ_LOG_BASE%/%RABBITMQ_NODENAME%.log"\"} ^
-sasl errlog_type error ^
--sasl sasl_error_logger {file,\""%LOG_BASE%/%NODENAME%-sasl.log"\"} ^
+-sasl sasl_error_logger {file,\""%RABBITMQ_LOG_BASE%/%RABBITMQ_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 ^
-os_mon memsup_system_only true ^
-os_mon system_memory_high_watermark 0.95 ^
--mnesia dir \""%MNESIA_DIR%"\" ^
+-mnesia dir \""%RABBITMQ_MNESIA_DIR%"\" ^
%CLUSTER_CONFIG% ^
-%RABBIT_ARGS% ^
+%RABBITMQ_SERVER_START_ARGS% ^
%*
-
diff --git a/scripts/rabbitmq-service.bat b/scripts/rabbitmq-service.bat index 4b9cc4529c..29be174284 100755 --- a/scripts/rabbitmq-service.bat +++ b/scripts/rabbitmq-service.bat @@ -11,37 +11,43 @@ 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 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 Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+REM Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+REM are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+REM Technologies LLC, and Rabbit Technologies Ltd.
+REM
+REM Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+REM Ltd. Portions created by Cohesive Financial Technologies LLC are
+REM Copyright (C) 2007-2009 Cohesive Financial Technologies
+REM LLC. Portions created by Rabbit Technologies Ltd are Copyright
+REM (C) 2007-2009 Rabbit Technologies Ltd.
REM
REM All Rights Reserved.
REM
REM Contributor(s): ______________________________________.
REM
-if "%SERVICENAME%"=="" (
- set SERVICENAME=RabbitMQ
+if "%RABBITMQ_SERVICENAME%"=="" (
+ set RABBITMQ_SERVICENAME=RabbitMQ
)
if "%RABBITMQ_BASE%"=="" (
- set RABBITMQ_BASE=%APPDATA%\%SERVICENAME%
+ set RABBITMQ_BASE=%APPDATA%\%RABBITMQ_SERVICENAME%
)
-if "%NODENAME%"=="" (
- set NODENAME=rabbit
+if "%RABBITMQ_NODENAME%"=="" (
+ set RABBITMQ_NODENAME=rabbit
)
-if "%NODE_IP_ADDRESS%"=="" (
- set NODE_IP_ADDRESS=0.0.0.0
+if "%RABBITMQ_NODE_IP_ADDRESS%"=="" (
+ set RABBITMQ_NODE_IP_ADDRESS=0.0.0.0
)
-if "%NODE_PORT%"=="" (
- set NODE_PORT=5672
+if "%RABBITMQ_NODE_PORT%"=="" (
+ set RABBITMQ_NODE_PORT=5672
)
if "%ERLANG_SERVICE_MANAGER_PATH%"=="" (
@@ -50,9 +56,9 @@ if "%ERLANG_SERVICE_MANAGER_PATH%"=="" ( set CONSOLE_FLAG=
set CONSOLE_LOG_VALID=
-for %%i in (new reuse) do if "%%i" == "%CONSOLE_LOG%" set CONSOLE_LOG_VALID=TRUE
+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 %CONSOLE_LOG%
+ set CONSOLE_FLAG=-debugtype %RABBITMQ_CONSOLE_LOG%
)
rem *** End of configuration ***
@@ -71,8 +77,13 @@ if not exist "%ERLANG_SERVICE_MANAGER_PATH%\erlsrv.exe" ( 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
+
+if "%RABBITMQ_MNESIA_BASE%"=="" (
+ set RABBITMQ_MNESIA_BASE=%RABBITMQ_BASE_UNIX%/db
+)
+if "%RABBITMQ_LOG_BASE%"=="" (
+ set RABBITMQ_LOG_BASE=%RABBITMQ_BASE_UNIX%/log
+)
rem We save the previous logs in their respective backup
@@ -80,11 +91,11 @@ rem Log management (rotation, filtering based on size...) is left as an exercise set BACKUP_EXTENSION=.1
-set LOGS="%RABBITMQ_BASE%\log\%NODENAME%.log"
-set SASL_LOGS="%RABBITMQ_BASE%\log\%NODENAME%-sasl.log"
+set LOGS="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%.log"
+set SASL_LOGS="%RABBITMQ_BASE%\log\%RABBITMQ_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%"
+set LOGS_BACKUP="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%.log%BACKUP_EXTENSION%"
+set SASL_LOGS_BACKUP="%RABBITMQ_BASE%\log\%RABBITMQ_NODENAME%-sasl.log%BACKUP_EXTENSION%"
if exist %LOGS% (
type %LOGS% >> %LOGS_BACKUP%
@@ -96,13 +107,17 @@ if exist %SASL_LOGS% ( rem End of log management
-set CLUSTER_CONFIG_FILE=%RABBITMQ_BASE%\rabbitmq_cluster.config
+if "%RABBITMQ_CLUSTER_CONFIG_FILE%"=="" (
+ set RABBITMQ_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:\=/%"\"
+if not exist "%RABBITMQ_CLUSTER_CONFIG_FILE%" GOTO L1
+set CLUSTER_CONFIG=-rabbit cluster_config \""%RABBITMQ_CLUSTER_CONFIG_FILE:\=/%"\"
:L1
-set MNESIA_DIR=%MNESIA_BASE%/%NODENAME%-mnesia
+if "%RABBITMQ_MNESIA_DIR%"=="" (
+ set RABBITMQ_MNESIA_DIR=%RABBITMQ_MNESIA_BASE%/%RABBITMQ_NODENAME%-mnesia
+)
if "%1" == "install" goto INSTALL_SERVICE
@@ -114,16 +129,16 @@ 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 %~n0 install - Install the %RABBITMQ_SERVICENAME% service
+echo %~n0 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 %~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 %~n0 start - Start the %RABBITMQ_SERVICENAME% service
+echo %~n0 stop - Stop the %RABBITMQ_SERVICENAME% service
+echo %~n0 disable - Disable the %RABBITMQ_SERVICENAME% service
+echo %~n0 enable - Enable the %RABBITMQ_SERVICENAME% service
echo.
exit /B
@@ -134,11 +149,11 @@ 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
+"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" list %RABBITMQ_SERVICENAME% 2>NUL 1>NUL
if errorlevel 1 (
- "%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" add %SERVICENAME%
+ "%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" add %RABBITMQ_SERVICENAME%
) else (
- echo %SERVICENAME% service is already present - only updating service parameters
+ echo %RABBITMQ_SERVICENAME% service is already present - only updating service parameters
)
set RABBIT_EBIN=%~dp0..\ebin
@@ -151,30 +166,30 @@ set ERLANG_SERVICE_ARGUMENTS= ^ +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"\"} ^
+-rabbit tcp_listeners "[{\"%RABBITMQ_NODE_IP_ADDRESS%\",%RABBITMQ_NODE_PORT%}]" ^
+-kernel error_logger {file,\""%RABBITMQ_LOG_BASE%/%RABBITMQ_NODENAME%.log"\"} ^
-sasl errlog_type error ^
--sasl sasl_error_logger {file,\""%LOG_BASE%/%NODENAME%-sasl.log"\"} ^
+-sasl sasl_error_logger {file,\""%RABBITMQ_LOG_BASE%/%RABBITMQ_NODENAME%-sasl.log"\"} ^
-os_mon start_cpu_sup true ^
-os_mon start_disksup false ^
--os_mon start_memsup true ^
+-os_mon start_memsup false ^
-os_mon start_os_sup false ^
-os_mon memsup_system_only true ^
-os_mon system_memory_high_watermark 0.95 ^
--mnesia dir \""%MNESIA_DIR%"\" ^
+-mnesia dir \""%RABBITMQ_MNESIA_DIR%"\" ^
%CLUSTER_CONFIG% ^
-%RABBIT_ARGS% ^
+%RABBITMQ_SERVER_START_ARGS% ^
%*
set ERLANG_SERVICE_ARGUMENTS=%ERLANG_SERVICE_ARGUMENTS:\=\\%
set ERLANG_SERVICE_ARGUMENTS=%ERLANG_SERVICE_ARGUMENTS:"=\"%
-"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" set %SERVICENAME% ^
+"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" set %RABBITMQ_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% ^
+-sname %RABBITMQ_NODENAME% ^
%CONSOLE_FLAG% ^
-args "%ERLANG_SERVICE_ARGUMENTS%" > NUL
goto END
@@ -182,8 +197,8 @@ goto END :MODIFY_SERVICE
-"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" %1 %SERVICENAME%
+"%ERLANG_SERVICE_MANAGER_PATH%\erlsrv" %1 %RABBITMQ_SERVICENAME%
goto END
-:END
\ No newline at end of file +:END
diff --git a/scripts/rabbitmqctl b/scripts/rabbitmqctl index bf00a9c733..b941b85005 100755 --- a/scripts/rabbitmqctl +++ b/scripts/rabbitmqctl @@ -11,13 +11,19 @@ ## ## The Original Code is RabbitMQ. ## -## The Initial Developers of the Original Code are LShift Ltd., -## Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +## The Initial Developers of the Original Code are LShift Ltd, +## Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. ## -## Portions created by LShift Ltd., Cohesive Financial Technologies -## LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -## LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -## Technologies Ltd.; +## Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +## Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +## Technologies LLC, and Rabbit Technologies Ltd. +## +## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +## Ltd. Portions created by Cohesive Financial Technologies LLC are +## Copyright (C) 2007-2009 Cohesive Financial Technologies +## LLC. Portions created by Rabbit Technologies Ltd are Copyright +## (C) 2007-2009 Rabbit Technologies Ltd. ## ## All Rights Reserved. ## diff --git a/scripts/rabbitmqctl.bat b/scripts/rabbitmqctl.bat index 1ee7e825b9..33a10777d0 100644..100755 --- a/scripts/rabbitmqctl.bat +++ b/scripts/rabbitmqctl.bat @@ -11,13 +11,19 @@ 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 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 Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+REM Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+REM are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+REM Technologies LLC, and Rabbit Technologies Ltd.
+REM
+REM Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
+REM Ltd. Portions created by Cohesive Financial Technologies LLC are
+REM Copyright (C) 2007-2009 Cohesive Financial Technologies
+REM LLC. Portions created by Rabbit Technologies Ltd are Copyright
+REM (C) 2007-2009 Rabbit Technologies Ltd.
REM
REM All Rights Reserved.
REM
diff --git a/src/buffering_proxy.erl b/src/buffering_proxy.erl index fcb7b412e2..344b719a3c 100644 --- a/src/buffering_proxy.erl +++ b/src/buffering_proxy.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit.erl b/src/rabbit.erl index 195dd729bd..41064c772c 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -157,8 +163,9 @@ start(normal, []) -> ok = rabbit_amqqueue:start(), - ok = rabbit_alarm:start(), - + {ok, MemoryAlarms} = application:get_env(memory_alarms), + ok = rabbit_alarm:start(MemoryAlarms), + ok = rabbit_binary_generator: check_empty_content_body_frame_size(), diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl index 4342e15b3b..b73090fc44 100644 --- a/src/rabbit_access_control.erl +++ b/src/rabbit_access_control.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -197,7 +203,7 @@ delete_vhost(VHostPath) -> lists:foreach(fun (Q) -> {ok,_} = rabbit_amqqueue:delete(Q, false, false) end, - rabbit_amqqueue:list_vhost_queues(VHostPath)), + rabbit_amqqueue:list(VHostPath)), R = rabbit_misc:execute_mnesia_transaction( rabbit_misc:with_vhost( VHostPath, @@ -211,7 +217,7 @@ internal_delete_vhost(VHostPath) -> lists:foreach(fun (#exchange{name=Name}) -> ok = rabbit_exchange:delete(Name, false) end, - rabbit_exchange:list_vhost_exchanges(VHostPath)), + rabbit_exchange:list(VHostPath)), lists:foreach(fun (Username) -> ok = unmap_user_vhost(Username, VHostPath) end, diff --git a/src/rabbit_alarm.erl b/src/rabbit_alarm.erl index 6d65b3a407..7bbed8b715 100644 --- a/src/rabbit_alarm.erl +++ b/src/rabbit_alarm.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -27,7 +33,7 @@ -behaviour(gen_event). --export([start/0, stop/0, register/2]). +-export([start/1, stop/0, register/2]). -export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2, code_change/3]). @@ -41,7 +47,7 @@ -ifdef(use_specs). -type(mfa_tuple() :: {atom(), atom(), list()}). --spec(start/0 :: () -> 'ok'). +-spec(start/1 :: (bool()) -> 'ok'). -spec(stop/0 :: () -> 'ok'). -spec(register/2 :: (pid(), mfa_tuple()) -> 'ok'). @@ -49,58 +55,15 @@ %%---------------------------------------------------------------------------- -start() -> - ok = alarm_handler:add_alarm_handler(?MODULE), +start(MemoryAlarms) -> + ok = alarm_handler:add_alarm_handler(?MODULE, [MemoryAlarms]), case whereis(memsup) of - undefined -> - Mod = case os:type() of - %% memsup doesn't take account of buffers or - %% cache when considering "free" memory - - %% therefore on Linux we can get memory alarms - %% very easily without any pressure existing on - %% memory at all. Therefore we need to use our - %% own simple memory monitor. - %% - {unix, linux} -> rabbit_memsup_linux; - - %% Start memsup programmatically rather than via - %% the rabbitmq-server script. This is not quite - %% the right thing to do as os_mon checks to see - %% if memsup is available before starting it, - %% but as memsup is available everywhere (even - %% on VXWorks) it should be ok. - %% - %% One benefit of the programmatic startup is - %% that we can add our alarm_handler before - %% memsup is running, thus ensuring that we - %% notice memory alarms that go off on startup. - %% - _ -> memsup - end, - %% This is based on os_mon:childspec(memsup, true) - {ok, _} = supervisor:start_child( - os_mon_sup, - {memsup, {Mod, start_link, []}, - permanent, 2000, worker, [Mod]}), - ok; - _ -> - ok - end, - %% The default memsup check interval is 1 minute, which is way too - %% long - rabbit can gobble up all memory in a matter of seconds. - %% Unfortunately the memory_check_interval configuration parameter - %% and memsup:set_check_interval/1 function only provide a - %% granularity of minutes. So we have to peel off one layer of the - %% API to get to the underlying layer which operates at the - %% granularity of milliseconds. - %% - %% Note that the new setting will only take effect after the first - %% check has completed, i.e. after one minute. So if rabbit eats - %% all the memory within the first minute after startup then we - %% are out of luck. - ok = os_mon:call(memsup, - {set_check_interval, ?MEMSUP_CHECK_INTERVAL}, - infinity). + undefined -> if MemoryAlarms -> ok = start_memsup(), + ok = adjust_memsup_interval(); + true -> ok + end; + _ -> ok = adjust_memsup_interval() + end. stop() -> ok = alarm_handler:delete_alarm_handler(?MODULE). @@ -111,9 +74,15 @@ register(Pid, HighMemMFA) -> %%---------------------------------------------------------------------------- -init([]) -> - {ok, #alarms{alertees = dict:new()}}. +init([MemoryAlarms]) -> + {ok, #alarms{alertees = case MemoryAlarms of + true -> dict:new(); + false -> undefined + end}}. +handle_call({register, _Pid, _HighMemMFA}, + State = #alarms{alertees = undefined}) -> + {ok, ok, State}; handle_call({register, Pid, HighMemMFA}, State = #alarms{alertees = Alertess}) -> _MRef = erlang:monitor(process, Pid), @@ -139,6 +108,9 @@ handle_event({clear_alarm, system_memory_high_watermark}, State) -> handle_event(_Event, State) -> {ok, State}. +handle_info({'DOWN', _MRef, process, _Pid, _Reason}, + State = #alarms{alertees = undefined}) -> + {ok, State}; handle_info({'DOWN', _MRef, process, Pid, _Reason}, State = #alarms{alertees = Alertess}) -> {ok, State#alarms{alertees = dict:erase(Pid, Alertess)}}; @@ -154,6 +126,56 @@ code_change(_OldVsn, State, _Extra) -> %%---------------------------------------------------------------------------- +start_memsup() -> + Mod = case os:type() of + %% memsup doesn't take account of buffers or cache when + %% considering "free" memory - therefore on Linux we can + %% get memory alarms very easily without any pressure + %% existing on memory at all. Therefore we need to use + %% our own simple memory monitor. + %% + {unix, linux} -> rabbit_memsup_linux; + + %% Start memsup programmatically rather than via the + %% rabbitmq-server script. This is not quite the right + %% thing to do as os_mon checks to see if memsup is + %% available before starting it, but as memsup is + %% available everywhere (even on VXWorks) it should be + %% ok. + %% + %% One benefit of the programmatic startup is that we + %% can add our alarm_handler before memsup is running, + %% thus ensuring that we notice memory alarms that go + %% off on startup. + %% + _ -> memsup + end, + %% This is based on os_mon:childspec(memsup, true) + {ok, _} = supervisor:start_child( + os_mon_sup, + {memsup, {Mod, start_link, []}, + permanent, 2000, worker, [Mod]}), + ok. + +adjust_memsup_interval() -> + %% The default memsup check interval is 1 minute, which is way too + %% long - rabbit can gobble up all memory in a matter of seconds. + %% Unfortunately the memory_check_interval configuration parameter + %% and memsup:set_check_interval/1 function only provide a + %% granularity of minutes. So we have to peel off one layer of the + %% API to get to the underlying layer which operates at the + %% granularity of milliseconds. + %% + %% Note that the new setting will only take effect after the first + %% check has completed, i.e. after one minute. So if rabbit eats + %% all the memory within the first minute after startup then we + %% are out of luck. + ok = os_mon:call(memsup, + {set_check_interval, ?MEMSUP_CHECK_INTERVAL}, + infinity). + +alert(_Alert, undefined) -> + ok; alert(Alert, Alertees) -> dict:fold(fun (Pid, {M, F, A}, Acc) -> ok = erlang:apply(M, F, A ++ [Pid, Alert]), diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index d142507df3..24ded98cc0 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -27,8 +33,9 @@ -export([start/0, recover/0, declare/4, delete/3, purge/1, internal_delete/1]). -export([pseudo_queue/2]). --export([lookup/1, with/2, with_or_die/2, list_vhost_queues/1, +-export([lookup/1, with/2, with_or_die/2, stat/1, stat_all/0, deliver/5, redeliver/2, requeue/3, ack/4]). +-export([list/1, info/1, info/2, info_all/1, info_all/2]). -export([claim_queue/2]). -export([basic_get/3, basic_consume/8, basic_cancel/4]). -export([notify_sent/2]). @@ -55,6 +62,7 @@ -type(qfun(A) :: fun ((amqqueue()) -> A)). -type(ok_or_errors() :: 'ok' | {'error', [{'error' | 'exit' | 'throw', any()}]}). + -spec(start/0 :: () -> 'ok'). -spec(recover/0 :: () -> 'ok'). -spec(declare/4 :: (queue_name(), bool(), bool(), amqp_table()) -> @@ -62,7 +70,11 @@ -spec(lookup/1 :: (queue_name()) -> {'ok', amqqueue()} | not_found()). -spec(with/2 :: (queue_name(), qfun(A)) -> A | not_found()). -spec(with_or_die/2 :: (queue_name(), qfun(A)) -> A). --spec(list_vhost_queues/1 :: (vhost()) -> [amqqueue()]). +-spec(list/1 :: (vhost()) -> [amqqueue()]). +-spec(info/1 :: (amqqueue()) -> [info()]). +-spec(info/2 :: (amqqueue(), [info_key()]) -> [info()]). +-spec(info_all/1 :: (vhost()) -> [[info()]]). +-spec(info_all/2 :: (vhost(), [info_key()]) -> [[info()]]). -spec(stat/1 :: (amqqueue()) -> qstats()). -spec(stat_all/0 :: () -> [qstats()]). -spec(delete/3 :: @@ -180,10 +192,25 @@ with_or_die(Name, F) -> not_found, "no ~s", [rabbit_misc:rs(Name)]) end). -list_vhost_queues(VHostPath) -> +list(VHostPath) -> mnesia:dirty_match_object( #amqqueue{name = rabbit_misc:r(VHostPath, queue), _ = '_'}). +map(VHostPath, F) -> rabbit_misc:filter_exit_map(F, list(VHostPath)). + +info(#amqqueue{ pid = QPid }) -> + gen_server:call(QPid, info). + +info(#amqqueue{ pid = QPid }, Items) -> + case gen_server:call(QPid, {info, Items}) of + {ok, Res} -> Res; + {error, Error} -> throw(Error) + end. + +info_all(VHostPath) -> map(VHostPath, fun (Q) -> info(Q) end). + +info_all(VHostPath, Items) -> map(VHostPath, fun (Q) -> info(Q, Items) end). + stat(#amqqueue{pid = QPid}) -> gen_server:call(QPid, stat). stat_all() -> diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 2000a11cbd..b2c619d3b8 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -63,6 +69,21 @@ is_overload_protection_active, unsent_message_count}). +-define(INFO_KEYS, + [name, + durable, + auto_delete, + arguments, + pid, + messages_ready, + messages_unacknowledged, + messages_uncommitted, + messages, + acks_uncommitted, + consumers, + transactions, + memory]). + %%---------------------------------------------------------------------------- start_link(Q) -> @@ -444,6 +465,9 @@ store_tx(Txn, Tx) -> erase_tx(Txn) -> erase({txn, Txn}). +all_tx_record() -> + [T || {{txn, _}, T} <- get()]. + all_tx() -> [Txn || {{txn, Txn}, _} <- get()]. @@ -495,8 +519,50 @@ purge_message_buffer(QName, MessageBuffer) -> %% artifically ack them. persist_acks(none, QName, lists:append(Messages)). +infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items]. + +i(name, #q{q = #amqqueue{name = Name}}) -> Name; +i(durable, #q{q = #amqqueue{durable = Durable}}) -> Durable; +i(auto_delete, #q{q = #amqqueue{auto_delete = AutoDelete}}) -> AutoDelete; +i(arguments, #q{q = #amqqueue{arguments = Arguments}}) -> Arguments; +i(pid, #q{q = #amqqueue{pid = Pid}}) -> Pid; +i(messages_ready, #q{message_buffer = MessageBuffer}) -> + queue:len(MessageBuffer); +i(messages_unacknowledged, _) -> + lists:sum([dict:size(UAM) || + #cr{unacked_messages = UAM} <- all_ch_record()]); +i(messages_uncommitted, _) -> + lists:sum([length(Pending) || + #tx{pending_messages = Pending} <- all_tx_record()]); +i(messages, State) -> + lists:sum([i(Item, State) || Item <- [messages_ready, + messages_unacknowledged, + messages_uncommitted]]); +i(acks_uncommitted, _) -> + lists:sum([length(Pending) || + #tx{pending_acks = Pending} <- all_tx_record()]); +i(consumers, _) -> + lists:sum([length(Consumers) || + #cr{consumers = Consumers} <- all_ch_record()]); +i(transactions, _) -> + length(all_tx_record()); +i(memory, _) -> + {memory, M} = process_info(self(), memory), + M; +i(Item, _) -> + throw({bad_argument, Item}). + %--------------------------------------------------------------------------- +handle_call(info, _From, State) -> + reply(infos(?INFO_KEYS, State), State); + +handle_call({info, Items}, _From, State) -> + try + reply({ok, infos(Items, State)}, State) + catch Error -> reply({error, Error}, State) + end; + handle_call({deliver_immediately, Txn, Message}, _From, State) -> %% Synchronous, "immediate" delivery mode %% diff --git a/src/rabbit_amqqueue_sup.erl b/src/rabbit_amqqueue_sup.erl index c68e2b3eda..46d23a4075 100644 --- a/src/rabbit_amqqueue_sup.erl +++ b/src/rabbit_amqqueue_sup.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl index 8b16abec70..6cfa9e6d17 100644 --- a/src/rabbit_binary_generator.erl +++ b/src/rabbit_binary_generator.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_binary_parser.erl b/src/rabbit_binary_parser.erl index e942521504..4ef382aaf5 100644 --- a/src/rabbit_binary_parser.erl +++ b/src/rabbit_binary_parser.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index b17a2b066f..b77d26a0c8 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index b821fa0dfa..ecc285a57f 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -113,14 +119,39 @@ Available commands: list_user_vhosts <UserName> list_vhost_users <VHostPath> + list_queues [-p <VHostPath>] [<QueueInfoItem> ...] + list_exchanges [-p <VHostPath>] [<ExchangeInfoItem> ...] + list_bindings [-p <VHostPath>] + list_connections [<ConnectionInfoItem> ...] + Quiet output mode is selected with the \"-q\" flag. Informational messages are suppressed when quiet mode is in effect. -<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. +<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 RABBITMQ_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. + +The list_queues, list_exchanges and list_bindings commands accept an optional +virtual host parameter for which to display results. The default value is \"/\". + +<QueueInfoItem> 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]. The default is + to display name and (number of) messages. + +<ExchangeInfoItem> must be a member of the list [name, type, durable, +auto_delete, arguments]. The default is to display name and type. + +The output format for \"list_bindings\" is a list of rows containing +exchange name, routing key, queue name and arguments, in that order. + +<ConnectionInfoItem> must be a member of the list [pid, address, port, +peer_address, peer_port, state, channels, user, vhost, timeout, frame_max, +recv_oct, recv_cnt, send_oct, send_cnt, send_pend]. The default is to display +user, peer_address and peer_port. "), halt(1). @@ -206,7 +237,85 @@ action(list_user_vhosts, Node, Args = [_Username], Inform) -> action(list_vhost_users, Node, Args = [_VHostPath], Inform) -> Inform("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, Inform) -> + Inform("Listing queues", []), + {VHostArg, RemainingArgs} = parse_vhost_flag(Args), + ArgAtoms = default_if_empty(RemainingArgs, [name, messages]), + display_info_list(rpc_call(Node, rabbit_amqqueue, info_all, + [VHostArg, ArgAtoms]), + ArgAtoms); + +action(list_exchanges, Node, Args, Inform) -> + Inform("Listing exchanges", []), + {VHostArg, RemainingArgs} = parse_vhost_flag(Args), + ArgAtoms = default_if_empty(RemainingArgs, [name, type]), + display_info_list(rpc_call(Node, rabbit_exchange, info_all, + [VHostArg, ArgAtoms]), + ArgAtoms); + +action(list_bindings, Node, Args, Inform) -> + Inform("Listing bindings", []), + {VHostArg, _} = parse_vhost_flag(Args), + InfoKeys = [exchange_name, routing_key, queue_name, args], + display_info_list( + [lists:zip(InfoKeys, tuple_to_list(X)) || + X <- rpc_call(Node, rabbit_exchange, list_bindings, [VHostArg])], + InfoKeys), + ok; + +action(list_connections, Node, Args, Inform) -> + Inform("Listing connections", []), + ArgAtoms = default_if_empty(Args, [user, peer_address, peer_port]), + display_info_list(rpc_call(Node, rabbit_networking, connection_info_all, + [ArgAtoms]), + ArgAtoms). + +parse_vhost_flag(Args) when is_list(Args) -> + case Args of + ["-p", VHost | RemainingArgs] -> + {list_to_binary(VHost), RemainingArgs}; + RemainingArgs -> + {<<"/">>, RemainingArgs} + end. + +default_if_empty(List, Default) when is_list(List) -> + if List == [] -> + Default; + true -> + [list_to_atom(X) || X <- List] + end. + +display_info_list(Results, InfoItemKeys) when is_list(Results) -> + lists:foreach( + fun (Result) -> + io:fwrite( + lists:flatten( + rabbit_misc:intersperse( + "\t", + [format_info_item(Result, X) || X <- InfoItemKeys]))), + io:nl() + end, + Results), + ok; + +display_info_list(Other, _) -> + Other. + +format_info_item(Items, Key) -> + {value, Info = {Key, Value}} = lists:keysearch(Key, 1, Items), + case Info of + {_, #resource{name = Name}} -> + url_encode(Name); + {Key, IpAddress} when Key =:= address; Key =:= peer_address + andalso is_tuple(IpAddress) -> + inet_parse:ntoa(IpAddress); + _ when is_binary(Value) -> + url_encode(Value); + _ -> + io_lib:format("~w", [Value]) + end. display_list(L) when is_list(L) -> lists:foreach(fun (I) -> @@ -221,3 +330,30 @@ call(Node, {Mod, Fun, Args}) -> rpc_call(Node, Mod, Fun, Args) -> rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT). + +%% url_encode is lifted from ibrowse, modified to preserve some characters +url_encode(Bin) when binary(Bin) -> + url_encode_char(lists:reverse(binary_to_list(Bin)), []). + +url_encode_char([X | T], Acc) when X >= $a, X =< $z -> + url_encode_char(T, [X | Acc]); +url_encode_char([X | T], Acc) when X >= $A, X =< $Z -> + url_encode_char(T, [X | Acc]); +url_encode_char([X | T], Acc) when X >= $0, X =< $9 -> + url_encode_char(T, [X | Acc]); +url_encode_char([X | T], Acc) + when X == $-; X == $_; X == $.; X == $~; + X == $!; X == $*; X == $'; X == $(; + X == $); X == $;; X == $:; X == $@; + X == $&; X == $=; X == $+; X == $$; + X == $,; X == $/; X == $?; X == $%; + X == $#; X == $[; X == $] -> + url_encode_char(T, [X | Acc]); +url_encode_char([X | T], Acc) -> + url_encode_char(T, [$%, d2h(X bsr 4), d2h(X band 16#0f) | Acc]); +url_encode_char([], Acc) -> + Acc. + +d2h(N) when N<10 -> N+$0; +d2h(N) -> N+$a-10. + diff --git a/src/rabbit_error_logger.erl b/src/rabbit_error_logger.erl index 9220d7b46f..dc5824f1c9 100644 --- a/src/rabbit_error_logger.erl +++ b/src/rabbit_error_logger.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_error_logger_file_h.erl b/src/rabbit_error_logger_file_h.erl index 7f7f77f5e1..9a9220b53e 100644 --- a/src/rabbit_error_logger_file_h.erl +++ b/src/rabbit_error_logger_file_h.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 58b8d7d60a..299747d141 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -29,10 +35,10 @@ -include("rabbit_framing.hrl"). -export([recover/0, declare/5, lookup/1, lookup_or_die/1, - list_vhost_exchanges/1, + list/1, info/1, info/2, info_all/1, info_all/2, simple_publish/6, simple_publish/3, route/2]). --export([add_binding/4, delete_binding/4]). +-export([add_binding/4, delete_binding/4, list_bindings/1]). -export([delete/2]). -export([delete_bindings_for_queue/1]). -export([check_type/1, assert_type/2, topic_matches/2]). @@ -62,7 +68,11 @@ -spec(assert_type/2 :: (exchange(), atom()) -> 'ok'). -spec(lookup/1 :: (exchange_name()) -> {'ok', exchange()} | not_found()). -spec(lookup_or_die/1 :: (exchange_name()) -> exchange()). --spec(list_vhost_exchanges/1 :: (vhost()) -> [exchange()]). +-spec(list/1 :: (vhost()) -> [exchange()]). +-spec(info/1 :: (exchange()) -> [info()]). +-spec(info/2 :: (exchange(), [info_key()]) -> [info()]). +-spec(info_all/1 :: (vhost()) -> [[info()]]). +-spec(info_all/2 :: (vhost(), [info_key()]) -> [[info()]]). -spec(simple_publish/6 :: (bool(), bool(), exchange_name(), routing_key(), binary(), binary()) -> publish_res()). @@ -74,6 +84,8 @@ -spec(delete_binding/4 :: (exchange_name(), queue_name(), routing_key(), amqp_table()) -> bind_res() | {'error', 'binding_not_found'}). +-spec(list_bindings/1 :: (vhost()) -> + [{exchange_name(), queue_name(), routing_key(), amqp_table()}]). -spec(delete_bindings_for_queue/1 :: (queue_name()) -> 'ok'). -spec(topic_matches/2 :: (binary(), binary()) -> bool()). -spec(delete/2 :: (exchange_name(), bool()) -> @@ -87,6 +99,8 @@ %%---------------------------------------------------------------------------- +-define(INFO_KEYS, [name, type, durable, auto_delete, arguments]. + recover() -> rabbit_misc:execute_mnesia_transaction( fun () -> @@ -154,10 +168,32 @@ lookup_or_die(Name) -> not_found, "no ~s", [rabbit_misc:rs(Name)]) end. -list_vhost_exchanges(VHostPath) -> +list(VHostPath) -> mnesia:dirty_match_object( #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}). +map(VHostPath, F) -> + %% TODO: there is scope for optimisation here, e.g. using a + %% cursor, parallelising the function invocation + lists:map(F, list(VHostPath)). + +infos(Items, X) -> [{Item, i(Item, X)} || Item <- Items]. + +i(name, #exchange{name = Name}) -> Name; +i(type, #exchange{type = Type}) -> Type; +i(durable, #exchange{durable = Durable}) -> Durable; +i(auto_delete, #exchange{auto_delete = AutoDelete}) -> AutoDelete; +i(arguments, #exchange{arguments = Arguments}) -> Arguments; +i(Item, _) -> throw({bad_argument, Item}). + +info(X = #exchange{}) -> infos(?INFO_KEYS, X). + +info(X = #exchange{}, Items) -> infos(Items, X). + +info_all(VHostPath) -> map(VHostPath, fun (X) -> info(X) end). + +info_all(VHostPath, Items) -> map(VHostPath, fun (X) -> info(X, Items) end). + %% Usable by Erlang code that wants to publish messages. simple_publish(Mandatory, Immediate, ExchangeName, RoutingKeyBin, ContentTypeBin, BodyBin) -> @@ -336,6 +372,19 @@ sync_binding(ExchangeName, QueueName, RoutingKey, Arguments, Durable, Fun) -> R <- tuple_to_list(route_with_reverse(Binding))], ok. +list_bindings(VHostPath) -> + [{ExchangeName, QueueName, RoutingKey, Arguments} || + #route{binding = #binding{ + exchange_name = ExchangeName, + key = RoutingKey, + queue_name = QueueName, + args = Arguments}} + <- mnesia:dirty_match_object( + #route{binding = #binding{ + exchange_name = rabbit_misc:r(VHostPath, exchange), + _ = '_'}, + _ = '_'})]. + route_with_reverse(#route{binding = Binding}) -> route_with_reverse(Binding); route_with_reverse(Binding = #binding{}) -> diff --git a/src/rabbit_framing_channel.erl b/src/rabbit_framing_channel.erl index 76c0461399..060bed4893 100644 --- a/src/rabbit_framing_channel.erl +++ b/src/rabbit_framing_channel.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_heartbeat.erl b/src/rabbit_heartbeat.erl index b05a4655e5..0a68c9adad 100644 --- a/src/rabbit_heartbeat.erl +++ b/src/rabbit_heartbeat.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_limiter.erl b/src/rabbit_limiter.erl index 8509eab8bd..d91893b0e8 100644 --- a/src/rabbit_limiter.erl +++ b/src/rabbit_limiter.erl @@ -1,5 +1,34 @@ -%% TODO Decide what to do with the license statement now that Cohesive have -%% bailed. +%% 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 +%% http://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 Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. +%% +%% All Rights Reserved. +%% +%% Contributor(s): ______________________________________. +%% + -module(rabbit_limiter). -behaviour(gen_server). diff --git a/src/rabbit_load.erl b/src/rabbit_load.erl index 2154bf72ae..7bf85347fb 100644 --- a/src/rabbit_load.erl +++ b/src/rabbit_load.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_log.erl b/src/rabbit_log.erl index b4729230e6..f408336e94 100644 --- a/src/rabbit_log.erl +++ b/src/rabbit_log.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_memsup_linux.erl b/src/rabbit_memsup_linux.erl index b77ffcabb4..ffdc7e9946 100644 --- a/src/rabbit_memsup_linux.erl +++ b/src/rabbit_memsup_linux.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 6be73e43a1..973e163b7a 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -34,7 +40,7 @@ -export([dirty_read/1]). -export([r/3, r/2, rs/1]). -export([enable_cover/0, report_cover/0]). --export([throw_on_error/2, with_exit_handler/2]). +-export([throw_on_error/2, with_exit_handler/2, filter_exit_map/2]). -export([with_user/2, with_vhost/2, with_user_and_vhost/3]). -export([execute_mnesia_transaction/1]). -export([ensure_ok/2]). @@ -81,6 +87,7 @@ -spec(throw_on_error/2 :: (atom(), thunk({error, any()} | {ok, A} | A)) -> A). -spec(with_exit_handler/2 :: (thunk(A), thunk(A)) -> A). +-spec(filter_exit_map/2 :: (fun ((A) -> B), [A]) -> [B]). -spec(with_user/2 :: (username(), thunk(A)) -> A). -spec(with_vhost/2 :: (vhost(), thunk(A)) -> A). -spec(with_user_and_vhost/3 :: (username(), vhost(), thunk(A)) -> A). @@ -218,6 +225,13 @@ with_exit_handler(Handler, Thunk) -> Handler() end. +filter_exit_map(F, L) -> + Ref = make_ref(), + lists:filter(fun (R) -> R =/= Ref end, + [with_exit_handler( + fun () -> Ref end, + fun () -> F(I) end) || I <- L]). + with_user(Username, Thunk) -> fun () -> case mnesia:read({user, Username}) of diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index ca8b587846..d19c37cb44 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -30,9 +36,6 @@ -export([table_names/0]). -%% Called by rabbitmq-mnesia-current script --export([schema_current/0]). - %% create_tables/0 exported for helping embed RabbitMQ in or alongside %% other mnesia-using Erlang applications, such as ejabberd -export([create_tables/0]). @@ -51,7 +54,6 @@ -spec(reset/0 :: () -> 'ok'). -spec(force_reset/0 :: () -> 'ok'). -spec(create_tables/0 :: () -> 'ok'). --spec(schema_current/0 :: () -> bool()). -endif. @@ -95,20 +97,6 @@ cluster(ClusterNodes) -> reset() -> reset(false). force_reset() -> reset(true). -%% This is invoked by rabbitmq-mnesia-current. -schema_current() -> - application:start(mnesia), - ok = ensure_mnesia_running(), - ok = ensure_mnesia_dir(), - ok = init_db(read_cluster_nodes_config()), - try - ensure_schema_integrity(), - true - catch - {error, {schema_integrity_check_failed, _Reason}} -> - false - end. - %%-------------------------------------------------------------------- table_definitions() -> @@ -163,17 +151,12 @@ ensure_mnesia_not_running() -> yes -> throw({error, mnesia_unexpectedly_running}) end. -ensure_schema_integrity() -> - case catch lists:foreach(fun (Tab) -> - mnesia:table_info(Tab, version) - end, - table_names()) of - {'EXIT', Reason} -> throw({error, {schema_integrity_check_failed, - Reason}}); - _ -> ok - end, +check_schema_integrity() -> %%TODO: more thorough checks - ok. + case catch [mnesia:table_info(Tab, version) || Tab <- table_names()] of + {'EXIT', Reason} -> {error, Reason}; + _ -> ok + end. %% The cluster node config file contains some or all of the disk nodes %% that are members of the cluster this node is / should be a part of. @@ -253,7 +236,20 @@ init_db(ClusterNodes) -> case mnesia:change_config(extra_db_nodes, ClusterNodes -- [node()]) of {ok, []} -> if WasDiskNode and IsDiskNode -> - ok; + case check_schema_integrity() of + ok -> + ok; + {error, Reason} -> + %% NB: we cannot use rabbit_log here since + %% it may not have been started yet + error_logger:warning_msg( + "schema integrity check failed: ~p~n" ++ + "moving database to backup location " ++ + "and recreating schema from scratch~n", + [Reason]), + ok = move_db(), + ok = create_schema() + end; WasDiskNode -> throw({error, {cannot_convert_disk_node_to_ram_node, ClusterNodes}}); @@ -286,6 +282,28 @@ create_schema() -> cannot_start_mnesia), create_tables(). +move_db() -> + mnesia:stop(), + MnesiaDir = filename:dirname(mnesia:system_info(directory) ++ "/"), + {{Year, Month, Day}, {Hour, Minute, Second}} = erlang:universaltime(), + BackupDir = lists:flatten( + io_lib:format("~s_~w~2..0w~2..0w~2..0w~2..0w~2..0w", + [MnesiaDir, + Year, Month, Day, Hour, Minute, Second])), + case file:rename(MnesiaDir, BackupDir) of + ok -> + %% NB: we cannot use rabbit_log here since it may not have + %% been started yet + error_logger:warning_msg("moved database from ~s to ~s~n", + [MnesiaDir, BackupDir]), + ok; + {error, Reason} -> throw({error, {cannot_backup_mnesia, + MnesiaDir, BackupDir, Reason}}) + end, + ok = ensure_mnesia_dir(), + rabbit_misc:ensure_ok(mnesia:start(), cannot_start_mnesia), + ok. + create_tables() -> lists:foreach(fun ({Tab, TabArgs}) -> case mnesia:create_table(Tab, TabArgs) of @@ -347,13 +365,17 @@ create_local_table_copy(Tab, Type) -> ok. wait_for_tables() -> - ok = ensure_schema_integrity(), - case mnesia:wait_for_tables(table_names(), 30000) of - ok -> ok; - {timeout, BadTabs} -> - throw({error, {timeout_waiting_for_tables, BadTabs}}); + case check_schema_integrity() of + ok -> + case mnesia:wait_for_tables(table_names(), 30000) of + ok -> ok; + {timeout, BadTabs} -> + throw({error, {timeout_waiting_for_tables, BadTabs}}); + {error, Reason} -> + throw({error, {failed_waiting_for_tables, Reason}}) + end; {error, Reason} -> - throw({error, {failed_waiting_for_tables, Reason}}) + throw({error, {schema_integrity_check_failed, Reason}}) end. reset(Force) -> diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl index b99dfbc1c1..7f6eaa8e93 100644 --- a/src/rabbit_multi.erl +++ b/src/rabbit_multi.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -84,8 +90,8 @@ action(start_all, [NodeCount], RpcTimeout) -> io:format("Starting all nodes...~n", []), N = list_to_integer(NodeCount), {NodePids, Running} = start_nodes(N, N, [], true, - getenv("NODENAME"), - getenv("NODE_PORT"), + getenv("RABBITMQ_NODENAME"), + getenv("RABBITMQ_NODE_PORT"), RpcTimeout), write_pids_file(NodePids), case Running of @@ -155,8 +161,8 @@ start_nodes(N, Total, PNodePid, Running, NodeNameBase, NodePortBase, RpcTimeout). start_node(NodeName, NodePort, RpcTimeout) -> - os:putenv("NODENAME", NodeName), - os:putenv("NODE_PORT", integer_to_list(NodePort)), + os:putenv("RABBITMQ_NODENAME", NodeName), + os:putenv("RABBITMQ_NODE_PORT", integer_to_list(NodePort)), Node = rabbit_misc:localnode(list_to_atom(NodeName)), io:format("Starting node ~s...~n", [Node]), case rpc:call(Node, os, getpid, []) of @@ -213,13 +219,13 @@ with_os(Handlers) -> end. script_filename() -> - ScriptHome = getenv("SCRIPT_HOME"), + ScriptHome = getenv("RABBITMQ_SCRIPT_HOME"), ScriptName = with_os( [{unix , fun () -> "rabbitmq-server" end}, {win32, fun () -> "rabbitmq-server.bat" end}]), ScriptHome ++ "/" ++ ScriptName ++ " -noinput". -pids_file() -> getenv("PIDS_FILE"). +pids_file() -> getenv("RABBITMQ_PIDS_FILE"). write_pids_file(Pids) -> FileName = pids_file(), diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl index a91602abb2..99ea37d884 100644 --- a/src/rabbit_networking.erl +++ b/src/rabbit_networking.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -26,7 +32,9 @@ -module(rabbit_networking). -export([start/0, start_tcp_listener/2, stop_tcp_listener/2, - on_node_down/1, active_listeners/0, node_listeners/1]). + on_node_down/1, active_listeners/0, node_listeners/1, + connections/0, connection_info/1, connection_info/2, + connection_info_all/0, connection_info_all/1]). %%used by TCP-based transports, e.g. STOMP adapter -export([check_tcp_listener_address/3]). @@ -40,12 +48,18 @@ -ifdef(use_specs). -type(host() :: ip_address() | string() | atom()). +-type(connection() :: pid()). -spec(start/0 :: () -> 'ok'). -spec(start_tcp_listener/2 :: (host(), ip_port()) -> 'ok'). -spec(stop_tcp_listener/2 :: (host(), ip_port()) -> 'ok'). -spec(active_listeners/0 :: () -> [listener()]). -spec(node_listeners/1 :: (erlang_node()) -> [listener()]). +-spec(connections/0 :: () -> [connection()]). +-spec(connection_info/1 :: (connection()) -> [info()]). +-spec(connection_info/2 :: (connection(), [info_key()]) -> [info()]). +-spec(connection_info_all/0 :: () -> [[info()]]). +-spec(connection_info_all/1 :: ([info_key()]) -> [[info()]]). -spec(on_node_down/1 :: (erlang_node()) -> 'ok'). -spec(check_tcp_listener_address/3 :: (atom(), host(), ip_port()) -> {ip_address(), atom()}). @@ -136,6 +150,16 @@ start_client(Sock) -> Child ! {go, Sock}, Child. +connections() -> + [Pid || {_, Pid, _, _} <- supervisor:which_children( + rabbit_tcp_client_sup)]. + +connection_info(Pid) -> rabbit_reader:info(Pid). +connection_info(Pid, Items) -> rabbit_reader:info(Pid, Items). + +connection_info_all() -> cmap(fun (Q) -> connection_info(Q) end). +connection_info_all(Items) -> cmap(fun (Q) -> connection_info(Q, Items) end). + %%-------------------------------------------------------------------- tcp_host({0,0,0,0}) -> @@ -149,3 +173,5 @@ tcp_host(IPAddress) -> {ok, #hostent{h_name = Name}} -> Name; {error, _Reason} -> inet_parse:ntoa(IPAddress) end. + +cmap(F) -> rabbit_misc:filter_exit_map(F, connections()). diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index 2fb582a9b9..14a69a472e 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_persister.erl b/src/rabbit_persister.erl index 91016d9d63..c34ad85100 100644 --- a/src/rabbit_persister.erl +++ b/src/rabbit_persister.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index ce26c11a0b..3f8d7cac5f 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -27,7 +33,7 @@ -include("rabbit_framing.hrl"). -include("rabbit.hrl"). --export([start_link/0]). +-export([start_link/0, info/1, info/2]). -export([system_continue/3, system_terminate/4, system_code_change/4]). @@ -50,6 +56,11 @@ -record(v1, {sock, connection, callback, recv_ref, connection_state}). +-define(INFO_KEYS, + [pid, address, port, peer_address, peer_port, + recv_oct, recv_cnt, send_oct, send_cnt, send_pend, + state, channels, user, vhost, timeout, frame_max]). + %% connection lifecycle %% %% all state transitions and terminations are marked with *...* @@ -120,6 +131,15 @@ %% %% TODO: refactor the code so that the above is obvious +%%---------------------------------------------------------------------------- + +-ifdef(use_specs). + +-spec(info/1 :: (pid()) -> [info()]). +-spec(info/2 :: (pid(), [info_key()]) -> [info()]). + +-endif. + %%-------------------------------------------------------------------------- start_link() -> @@ -140,6 +160,15 @@ system_terminate(Reason, _Parent, _Deb, _State) -> system_code_change(Misc, _Module, _OldVsn, _Extra) -> {ok, Misc}. +info(Pid) -> + gen_server:call(Pid, info). + +info(Pid, Items) -> + case gen_server:call(Pid, {info, Items}) of + {ok, Res} -> Res; + {error, Error} -> throw(Error) + end. + setup_profiling() -> Value = rabbit_misc:get_config(profiling_enabled, false), case Value of @@ -270,6 +299,14 @@ mainloop(Parent, Deb, State = #v1{sock= Sock, recv_ref = Ref}) -> end; timeout -> throw({timeout, State#v1.connection_state}); + {'$gen_call', From, info} -> + gen_server:reply(From, infos(?INFO_KEYS, State)), + mainloop(Parent, Deb, State); + {'$gen_call', From, {info, Items}} -> + gen_server:reply(From, try {ok, infos(Items, State)} + catch Error -> {error, Error} + end), + mainloop(Parent, Deb, State); {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, Deb, State); @@ -617,6 +654,51 @@ compute_redirects(false) -> %%-------------------------------------------------------------------------- +infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items]. + +i(pid, #v1{}) -> + self(); +i(address, #v1{sock = Sock}) -> + {ok, {A, _}} = inet:sockname(Sock), + A; +i(port, #v1{sock = Sock}) -> + {ok, {_, P}} = inet:sockname(Sock), + P; +i(peer_address, #v1{sock = Sock}) -> + {ok, {A, _}} = inet:peername(Sock), + A; +i(peer_port, #v1{sock = Sock}) -> + {ok, {_, P}} = inet:peername(Sock), + P; +i(SockStat, #v1{sock = Sock}) when SockStat =:= recv_oct; + SockStat =:= recv_cnt; + SockStat =:= send_oct; + SockStat =:= send_cnt; + SockStat =:= send_pend -> + case inet:getstat(Sock, [SockStat]) of + {ok, [{SockStat, StatVal}]} -> StatVal; + {error, einval} -> undefined; + {error, Error} -> throw({cannot_get_socket_stats, Error}) + end; +i(state, #v1{connection_state = S}) -> + S; +i(channels, #v1{}) -> + length(all_channels()); +i(user, #v1{connection = #connection{user = #user{username = Username}}}) -> + Username; +i(user, #v1{connection = #connection{user = none}}) -> + none; +i(vhost, #v1{connection = #connection{vhost = VHost}}) -> + VHost; +i(timeout, #v1{connection = #connection{timeout_sec = Timeout}}) -> + Timeout; +i(frame_max, #v1{connection = #connection{frame_max = FrameMax}}) -> + FrameMax; +i(Item, #v1{}) -> + throw({bad_argument, Item}). + +%%-------------------------------------------------------------------------- + send_to_new_channel(Channel, AnalyzedFrame, State) -> case get({closing_channel, Channel}) of undefined -> diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl index 58eb5b54f6..ad653a2f2a 100644 --- a/src/rabbit_router.erl +++ b/src/rabbit_router.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_sasl_report_file_h.erl b/src/rabbit_sasl_report_file_h.erl index e2385d83ba..9e4c9c8a31 100644 --- a/src/rabbit_sasl_report_file_h.erl +++ b/src/rabbit_sasl_report_file_h.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_sup.erl b/src/rabbit_sup.erl index ea55869004..730d7909bc 100644 --- a/src/rabbit_sup.erl +++ b/src/rabbit_sup.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index d7c8bddf03..df2e71d9e6 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% @@ -29,6 +35,7 @@ -import(lists). +-include("rabbit.hrl"). -include_lib("kernel/include/file.hrl"). test_content_prop_roundtrip(Datum, Binary) -> @@ -45,6 +52,7 @@ all_tests() -> passed = test_log_management_during_startup(), passed = test_cluster_management(), passed = test_user_management(), + passed = test_server_status(), passed. test_parsing() -> @@ -131,8 +139,6 @@ test_topic_matching() -> passed. test_app_management() -> - true = rabbit_mnesia:schema_current(), - %% starting, stopping, status ok = control_action(stop_app, []), ok = control_action(stop_app, []), @@ -488,12 +494,57 @@ test_user_management() -> passed. +test_server_status() -> + + %% create a queue so we have something to list + Q = #amqqueue{} = rabbit_amqqueue:declare( + rabbit_misc:r(<<"/">>, queue, <<"foo">>), + false, false, []), + + %% list queues + ok = info_action( + list_queues, + [name, durable, auto_delete, arguments, pid, + messages_ready, messages_unacknowledged, messages_uncommitted, + messages, acks_uncommitted, consumers, transactions, memory], + true), + + %% list exchanges + ok = info_action( + list_exchanges, + [name, type, durable, auto_delete, arguments], + true), + + %% list bindings + ok = control_action(list_bindings, []), + + %% cleanup + {ok, _} = rabbit_amqqueue:delete(Q, false, false), + + %% list connections + [#listener{host = H, port = P} | _] = rabbit_networking:active_listeners(), + {ok, C} = gen_tcp:connect(H, P, []), + timer:sleep(100), + ok = info_action( + list_connections, + [pid, address, port, peer_address, peer_port, state, + channels, user, vhost, timeout, frame_max, + recv_oct, recv_cnt, send_oct, send_cnt, send_pend], + false), + ok = gen_tcp:close(C), + + passed. + %--------------------------------------------------------------------- control_action(Command, Args) -> control_action(Command, node(), Args). control_action(Command, Node, Args) -> - case catch rabbit_control:action(Command, Node, Args, fun io:format/2) of + case catch rabbit_control:action( + Command, Node, Args, + fun (Format, Args1) -> + io:format(Format ++ " ...~n", Args1) + end) of ok -> io:format("done.~n"), ok; @@ -502,6 +553,15 @@ control_action(Command, Node, Args) -> Other end. +info_action(Command, Args, CheckVHost) -> + ok = control_action(Command, []), + if CheckVHost -> ok = control_action(Command, ["-p", "/"]); + true -> ok + end, + ok = control_action(Command, lists:map(fun atom_to_list/1, Args)), + {bad_argument, dummy} = control_action(Command, ["dummy"]), + ok. + empty_files(Files) -> [case file:read_file_info(File) of {ok, FInfo} -> FInfo#file_info.size == 0; diff --git a/src/rabbit_tracer.erl b/src/rabbit_tracer.erl index 5365b8732f..0c023f2aab 100644 --- a/src/rabbit_tracer.erl +++ b/src/rabbit_tracer.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/rabbit_writer.erl b/src/rabbit_writer.erl index a2688625be..9cf9f8aef9 100644 --- a/src/rabbit_writer.erl +++ b/src/rabbit_writer.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/tcp_acceptor.erl b/src/tcp_acceptor.erl index 3e4c5ee423..aa8b8ad5a7 100644 --- a/src/tcp_acceptor.erl +++ b/src/tcp_acceptor.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/tcp_acceptor_sup.erl b/src/tcp_acceptor_sup.erl index a3144e410c..f2bad5bc2e 100644 --- a/src/tcp_acceptor_sup.erl +++ b/src/tcp_acceptor_sup.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/tcp_client_sup.erl b/src/tcp_client_sup.erl index 4e1b9c6b30..d92066a6c3 100644 --- a/src/tcp_client_sup.erl +++ b/src/tcp_client_sup.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/tcp_listener.erl b/src/tcp_listener.erl index dc38b5941c..92a47cf127 100644 --- a/src/tcp_listener.erl +++ b/src/tcp_listener.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% diff --git a/src/tcp_listener_sup.erl b/src/tcp_listener_sup.erl index 9347240668..901a0da3b7 100644 --- a/src/tcp_listener_sup.erl +++ b/src/tcp_listener_sup.erl @@ -10,13 +10,19 @@ %% %% The Original Code is RabbitMQ. %% -%% The Initial Developers of the Original Code are LShift Ltd., -%% Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd. +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd., Cohesive Financial Technologies -%% LLC., and Rabbit Technologies Ltd. are Copyright (C) 2007-2008 -%% LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit -%% Technologies Ltd.; +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% |
