diff options
author | Matthias Radestock <matthias@lshift.net> | 2008-12-02 18:02:13 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2008-12-02 18:02:13 +0000 |
commit | 2d129846c0595033cca46744f5e47dcbbb5b57d3 (patch) | |
tree | 7517e5d173fd84ea8adc2faf375d1d4b51f34a9c | |
parent | 8ccbaf672f08340dd5985060c0e4bda3a4d0096e (diff) | |
parent | 7949ac7cbb8587a54fb16bf97e877d08533f9b84 (diff) | |
download | rabbitmq-server-2d129846c0595033cca46744f5e47dcbbb5b57d3.tar.gz |
merge default into bug19684
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | codegen.py | 3 | ||||
-rw-r--r-- | packaging/RPMS/Fedora/rabbitmq-server.spec | 2 | ||||
-rw-r--r-- | packaging/debs/Debian/debian/control | 4 | ||||
-rw-r--r-- | packaging/debs/Debian/debian/postinst | 22 | ||||
-rw-r--r-- | packaging/debs/Debian/debian/templates | 16 | ||||
-rwxr-xr-x | scripts/rabbitmq-mnesia-current | 49 | ||||
-rw-r--r-- | src/rabbit_mnesia.erl | 18 | ||||
-rw-r--r-- | src/rabbit_tests.erl | 2 |
9 files changed, 116 insertions, 4 deletions
@@ -63,6 +63,9 @@ cleandb: stop-node 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 +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-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 @@ -134,6 +137,7 @@ install: all 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 > \ @@ -58,7 +58,8 @@ erlangDefaultValueTypeConvMap = { str : lambda x: "<<\"" + x + "\">>", int : lambda x: str(x), float : lambda x: str(x), - dict: convertTable + dict: convertTable, + unicode: lambda x: "<<\"" + x.encode("utf-8") + "\">>" } def erlangize(s): diff --git a/packaging/RPMS/Fedora/rabbitmq-server.spec b/packaging/RPMS/Fedora/rabbitmq-server.spec index 23ebecef..9067a844 100644 --- a/packaging/RPMS/Fedora/rabbitmq-server.spec +++ b/packaging/RPMS/Fedora/rabbitmq-server.spec @@ -11,7 +11,7 @@ URL: http://www.rabbitmq.com/ Vendor: LShift Ltd., Cohesive Financial Technologies LLC., Rabbit Technlogies Ltd. %if 0%{?debian} %else -BuildRequires: erlang, python-json +BuildRequires: erlang, python-simplejson %endif Requires: erlang, logrotate Packager: Hubert Plociniczak <hubert@lshift.net> diff --git a/packaging/debs/Debian/debian/control b/packaging/debs/Debian/debian/control index 749791a4..f6761713 100644 --- a/packaging/debs/Debian/debian/control +++ b/packaging/debs/Debian/debian/control @@ -2,12 +2,12 @@ Source: rabbitmq-server Section: net Priority: extra Maintainer: Tony Garnock-Jones <tonyg@rabbitmq.com> -Build-Depends: cdbs, debhelper (>= 5), erlang-nox, erlang-dev, python-json +Build-Depends: cdbs, debhelper (>= 5), erlang-nox, erlang-dev, python-simplejson Standards-Version: 3.7.2 Package: rabbitmq-server Architecture: all -Depends: erlang-nox, adduser, logrotate +Depends: erlang-nox, adduser, logrotate, debconf 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/postinst b/packaging/debs/Debian/debian/postinst index f92131d0..13d8552f 100644 --- a/packaging/debs/Debian/debian/postinst +++ b/packaging/debs/Debian/debian/postinst @@ -34,6 +34,28 @@ 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/templates b/packaging/debs/Debian/debian/templates new file mode 100644 index 00000000..89f5754b --- /dev/null +++ b/packaging/debs/Debian/debian/templates @@ -0,0 +1,16 @@ +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/scripts/rabbitmq-mnesia-current b/scripts/rabbitmq-mnesia-current new file mode 100755 index 00000000..21f04f88 --- /dev/null +++ b/scripts/rabbitmq-mnesia-current @@ -0,0 +1,49 @@ +#!/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 \ + -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/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 8d34d285..ca8b5878 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -30,6 +30,9 @@ -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]). @@ -48,6 +51,7 @@ -spec(reset/0 :: () -> 'ok'). -spec(force_reset/0 :: () -> 'ok'). -spec(create_tables/0 :: () -> 'ok'). +-spec(schema_current/0 :: () -> bool()). -endif. @@ -91,6 +95,20 @@ 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() -> diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index db78bbcc..09e2cfe4 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -131,6 +131,8 @@ 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, []), |