summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert@lshift.net>2008-09-05 17:02:01 +0100
committerHubert Plociniczak <hubert@lshift.net>2008-09-05 17:02:01 +0100
commit300855b22d31305bf385293d5504a9271136a3f8 (patch)
tree10eeb2a45c0018a164e0e1409408575686d1c99b
parent06a8be7b93aa617cf927a7c356913721a003971b (diff)
parent5a4dcf246250bd44300bca11ccf07d656b0cfbc2 (diff)
downloadrabbitmq-server-300855b22d31305bf385293d5504a9271136a3f8.tar.gz
Merge bug19200 into bug19193
-rw-r--r--docs/rabbitmq-multi.pod3
-rw-r--r--packaging/RPMS/Fedora/Makefile1
-rw-r--r--packaging/RPMS/Fedora/init.d85
-rw-r--r--packaging/RPMS/Fedora/rabbitmq-server.logrotate12
-rw-r--r--packaging/RPMS/Fedora/rabbitmq-server.spec126
-rw-r--r--packaging/debs/Debian/debian/control2
-rw-r--r--packaging/debs/Debian/debian/dirs1
-rw-r--r--packaging/debs/Debian/debian/init.d23
-rw-r--r--packaging/debs/Debian/debian/rabbitmq-server.logrotate12
-rw-r--r--packaging/debs/Debian/debian/rules1
-rwxr-xr-xscripts/rabbitmq-server2
-rw-r--r--scripts/rabbitmq-server.bat2
-rw-r--r--src/rabbit_multi.erl38
13 files changed, 204 insertions, 104 deletions
diff --git a/docs/rabbitmq-multi.pod b/docs/rabbitmq-multi.pod
index 2e3f28c8..772ca70a 100644
--- a/docs/rabbitmq-multi.pod
+++ b/docs/rabbitmq-multi.pod
@@ -26,6 +26,9 @@ start_all I<count>
stop_all
stop all local RabbitMQ nodes
+rotate_logs_all
+ rotate log files for all local RabbitMQ nodes
+
=head1 EXAMPLES
Start 3 local RabbitMQ nodes with unique, sequential port numbers:
diff --git a/packaging/RPMS/Fedora/Makefile b/packaging/RPMS/Fedora/Makefile
index c8e979a7..6cc3579b 100644
--- a/packaging/RPMS/Fedora/Makefile
+++ b/packaging/RPMS/Fedora/Makefile
@@ -21,6 +21,7 @@ prepare:
cp $(TOP_DIR)/rabbitmq-server.spec $(TOP_DIR)/SPECS
cp $(TOP_DIR)/init.d $(TOP_DIR)/BUILD
cp $(TOP_DIR)/rabbitmqctl_wrapper $(TOP_DIR)/BUILD
+ cp $(TOP_DIR)/rabbitmq-server.logrotate $(TOP_DIR)/BUILD
server: prepare
rpmbuild -ba $(TOP_DIR)/SPECS/rabbitmq-server.spec $(DEFINES) --target noarch
diff --git a/packaging/RPMS/Fedora/init.d b/packaging/RPMS/Fedora/init.d
index 09ca02c9..dc0c2698 100644
--- a/packaging/RPMS/Fedora/init.d
+++ b/packaging/RPMS/Fedora/init.d
@@ -1,57 +1,95 @@
#!/bin/sh
+#
+# rabbitmq-server RabbitMQ broker
+#
+#chkconfig: 2345 80 05
+#description: Enable AMQP service provided by RabbitMQ
+#
+
### BEGIN INIT INFO
# Provides: rabbitmq
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
+# Description: RabbitMQ broker
+# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
-#chkconfig: 2345 80 05
-#description: RabbitMQ Server
-
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/usr/sbin/rabbitmq-multi
+DAEMON_NAME=rabbitmq-multi
+DAEMON=/usr/sbin/$DAEMON_NAME
NAME=rabbitmq-server
DESC=rabbitmq-server
USER=rabbitmq
NODE_COUNT=1
+ROTATE_SUFFIX=
+
+LOCK_FILE=/var/lock/subsys/$NAME
test -x $DAEMON || exit 0
+# source function library
+. /etc/rc.d/init.d/functions
+
# Include rabbitmq defaults if available
if [ -f /etc/default/rabbitmq ] ; then
. /etc/default/rabbitmq
fi
+RETVAL=0
set -e
cd /
start_rabbitmq () {
set +e
- su rabbitmq -s /bin/sh -c "$DAEMON start_all ${NODE_COUNT}" > /var/log/rabbitmq/startup.log 2> /var/log/rabbitmq/startup.err
+ su $USER -s /bin/sh -c "$DAEMON start_all ${NODE_COUNT}" > /var/log/rabbitmq/startup.log 2> /var/log/rabbitmq/startup.err
case "$?" in
0)
- echo SUCCESS;;
+ echo SUCCESS && touch $LOCK_FILE
+ ;;
1)
- echo TIMEOUT - check /var/log/rabbitmq/startup.\{log,err\};;
+ echo TIMEOUT - check /var/log/rabbitmq/startup.\{log,err\}
+ ;;
*)
echo FAILED - check /var/log/rabbitmq/startup.log, .err
- exit 1;;
+ RETVAL=1;;
esac
set -e
}
stop_rabbitmq () {
set +e
- su rabbitmq -s /bin/sh -c "$DAEMON stop_all" > /var/log/rabbitmq/shutdown.log 2> /var/log/rabbitmq/shutdown.err
+ su $USER -s /bin/sh -c "$DAEMON stop_all" > /var/log/rabbitmq/shutdown.log 2> /var/log/rabbitmq/shutdown.err
+
if [ $? != 0 ] ; then
echo FAILED - check /var/log/rabbitmq/shutdown.log, .err
- exit 0
+ RETVAL=$?
+ else
+ rm -rf $LOCK_FILE
+ RETVAL=0
fi
set -e
}
+status_rabbitmq () {
+ status $NAME
+}
+
+restart_rabbitmq () {
+ echo -n "Restarting $DESC: "
+ stop_rabbitmq
+ start_rabbitmq
+ echo "$NAME."
+}
+
+rotate_logs_rabbitmq() {
+ set +e
+ su $USER -s /bin/sh -c "$DAEMON rotate_logs_all ${ROTATE_SUFFIX}" 2>&1
+ RETVAL=$?
+ set -e
+}
+
case "$1" in
start)
echo -n "Starting $DESC: "
@@ -63,17 +101,26 @@ case "$1" in
stop_rabbitmq
echo "$NAME."
;;
- force-reload|restart)
- echo -n "Restarting $DESC: "
- stop_rabbitmq
- start_rabbitmq
- echo "$NAME."
+ rotate-logs)
+ echo -n "Rotating log files for $DESC: "
+ rotate_logs_rabbitmq
+ ;;
+ force-reload|reload|restart)
+ restart_rabbitmq
+ ;;
+ status)
+ echo "Status of $DESC: "
+ status_rabbitmq
+ RETVAL=$?
;;
+ condrestart|try-restart)
+ status_rabbitmq >/dev/null 2>&1 || exit 0
+ restart_rabbitmq
+ ;;
*)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload}" >&2
- exit 1
+ echo "Usage: $0 {start|stop|rotate-logs|status|restart|condrestart|try-restart|reload|force-reload}" >&2
+ RETVAL=1
;;
esac
-exit 0
+exit $RETVAL
diff --git a/packaging/RPMS/Fedora/rabbitmq-server.logrotate b/packaging/RPMS/Fedora/rabbitmq-server.logrotate
new file mode 100644
index 00000000..64cd01a1
--- /dev/null
+++ b/packaging/RPMS/Fedora/rabbitmq-server.logrotate
@@ -0,0 +1,12 @@
+/var/log/rabbitmq/*.log {
+ weekly
+ missingok
+ rotate 20
+ compress
+ delaycompress
+ notifempty
+ sharedscripts
+ postrotate
+ /sbin/service rabbitmq-server rotate-logs
+ endscript
+} \ No newline at end of file
diff --git a/packaging/RPMS/Fedora/rabbitmq-server.spec b/packaging/RPMS/Fedora/rabbitmq-server.spec
index 25213816..4e39012c 100644
--- a/packaging/RPMS/Fedora/rabbitmq-server.spec
+++ b/packaging/RPMS/Fedora/rabbitmq-server.spec
@@ -1,75 +1,68 @@
-%define source_name rabbitmq-server
-
Name: rabbitmq-server
Version: %{rpm_version}
Release: 1
-License: Mozilla Public License
+License: MPLv1.1
Group: Development/Libraries
-Source: http://www.rabbitmq.com/releases/%{source_name}-%{main_version}.tar.gz
+Source: http://www.rabbitmq.com/releases/rabbitmq-server/v%{main_version}/%{name}-%{main_version}.tar.gz
URL: http://www.rabbitmq.com/
Vendor: LShift Ltd., Cohesive Financial Technologies LLC., Rabbit Technlogies Ltd.
-Requires: erlang
+Requires: erlang, logrotate
Packager: Hubert Plociniczak <hubert@lshift.net>
BuildRoot: %{_tmppath}/%{name}-%{main_version}-%{release}-root
Summary: The RabbitMQ server
+Requires(post): chkconfig
+Requires(pre): chkconfig initscripts
%description
RabbitMQ is an implementation of AMQP, the emerging standard for high
performance enterprise messaging. The RabbitMQ server is a robust and
scalable implementation of an AMQP broker.
-%define _libdir /usr/lib/erlang
-%define _docdir /usr/share/doc
+
%define _mandir /usr/share/man
-%define _maindir $RPM_BUILD_ROOT%{_libdir}/lib/rabbitmq_server-%{main_version}
-%define package_name rabbitmq-server-dist
+%define _sbindir /usr/sbin
+%define _libdir %(erl -noshell -eval "io:format('~s~n', [code:lib_dir()]), halt().")
+%define _maindir %{buildroot}%{_libdir}/rabbitmq_server-%{main_version}
+
%pre
if [ $1 -gt 1 ]; then
- #Upgrade - stop and remove previous instance of rabbitmq init.d script
- /etc/init.d/rabbitmq-server stop
+ #Upgrade - stop and remove previous instance of rabbitmq-server init.d script
+ /sbin/service rabbitmq-server stop
/sbin/chkconfig --del rabbitmq-server
fi
%prep
-%setup -n %{source_name}-%{main_version}
+%setup -n %{name}-%{main_version}
%build
-mkdir %{package_name}
-mkdir %{package_name}/sbin
-mkdir %{package_name}/man
-make install TARGET_DIR=`pwd`/%{package_name} \
- SBIN_DIR=`pwd`/%{package_name}/sbin \
- MAN_DIR=`pwd`/%{package_name}/man
- VERSION=%{main_version}
+make
%install
-mkdir -p %{_maindir}
-mkdir -p $RPM_BUILD_ROOT%{_docdir}/rabbitmq-server
-mkdir -p $RPM_BUILD_ROOT/etc/init.d
-mkdir -p $RPM_BUILD_ROOT/usr/sbin
-mkdir -p $RPM_BUILD_ROOT%{_mandir}
+rm -rf %{buildroot}
-mkdir -p $RPM_BUILD_ROOT/var/lib/rabbitmq/mnesia
-mkdir -p $RPM_BUILD_ROOT/var/log/rabbitmq
+make install TARGET_DIR=%{_maindir} \
+ SBIN_DIR=%{buildroot}%{_sbindir} \
+ MAN_DIR=%{buildroot}%{_mandir}
+ VERSION=%{main_version}
-#Copy all necessary lib files etc.
-cp -r %{package_name}/ebin %{_maindir}
-cp -r %{package_name}/src %{_maindir}
-cp -r %{package_name}/include %{_maindir}
-chmod 755 %{package_name}/sbin/*
-cp %{package_name}/sbin/* $RPM_BUILD_ROOT/usr/sbin/
-cp -r %{package_name}/man/* $RPM_BUILD_ROOT%{_mandir}/
+mkdir -p %{buildroot}/var/lib/rabbitmq/mnesia
+mkdir -p %{buildroot}/var/log/rabbitmq
+mkdir -p %{buildroot}/etc/rc.d/init.d/
-cp ../init.d $RPM_BUILD_ROOT/etc/init.d/rabbitmq-server
-chmod 775 $RPM_BUILD_ROOT/etc/init.d/rabbitmq-server
+#Copy all necessary lib files etc.
+cp ../init.d %{buildroot}/etc/rc.d/init.d/rabbitmq-server
+chmod 0755 %{buildroot}/etc/rc.d/init.d/rabbitmq-server
-mv $RPM_BUILD_ROOT/usr/sbin/rabbitmqctl $RPM_BUILD_ROOT/usr/sbin/rabbitmqctl_real
-cp ../rabbitmqctl_wrapper $RPM_BUILD_ROOT/usr/sbin/rabbitmqctl
-chmod 755 $RPM_BUILD_ROOT/usr/sbin/rabbitmqctl
+mv %{buildroot}/usr/sbin/rabbitmqctl %{buildroot}/usr/sbin/rabbitmqctl_real
+cp ../rabbitmqctl_wrapper %{buildroot}/usr/sbin/rabbitmqctl
+chmod 0755 %{buildroot}/usr/sbin/rabbitmqctl
cp %{buildroot}%{_mandir}/man1/rabbitmqctl.1.gz %{buildroot}%{_mandir}/man1/rabbitmqctl_real.1.gz
+mkdir -p %{buildroot}/etc/logrotate.d
+cp ../rabbitmq-server.logrotate %{buildroot}/etc/logrotate.d/rabbitmq-server
+
%post
# create rabbitmq group
if ! getent group rabbitmq >/dev/null; then
@@ -82,65 +75,58 @@ if ! getent passwd rabbitmq >/dev/null; then
usermod -c "Rabbit AMQP Messaging Server" rabbitmq
fi
-# On 64bit /usr/lib64 contains Erlang, not /usr/lib. Fix with a symlink
-ERL_LIB_DIR=$(erl -noshell -eval "io:format(\"~s~n\", [code:lib_dir()]), halt().")
-if [ ! ${ERL_LIB_DIR} = "/usr/lib/erlang/lib" ] ; then
- ln -s /usr/lib/erlang/lib/rabbitmq_server-%{main_version} ${ERL_LIB_DIR}
-fi
-
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq
chown -R rabbitmq:rabbitmq /var/log/rabbitmq
-/sbin/chkconfig --add rabbitmq-server
-/etc/init.d/rabbitmq-server start
+/sbin/chkconfig --add %{name}
%preun
if [ $1 = 0 ]; then
#Complete uninstall
- /etc/init.d/rabbitmq-server stop
+ /sbin/service rabbitmq-server stop > /dev/null 2>&1
/sbin/chkconfig --del rabbitmq-server
-
- # Remove symlink we added above
- ERL_LIB_DIR=$(erl -noshell -eval "io:format(\"~s~n\", [code:lib_dir()]), halt().")
- if [ ! ${ERL_LIB_DIR} = "/usr/lib/erlang/lib" ] ; then
- rm ${ERL_LIB_DIR}/rabbitmq_server-%{main_version}
- fi
- # We do not remove log and lib directories
+ # We do not remove /var/log and /var/lib directories
# Leave rabbitmq user and group
fi
%files
-%defattr(-,root,root)
-%{_libdir}/lib/rabbitmq_server-%{main_version}/
-%{_docdir}/rabbitmq-server/
-%{_mandir}
-/usr/sbin
-/var/lib/rabbitmq
-/var/log/rabbitmq
-/etc/init.d/rabbitmq-server
+%defattr(-,root,root,-)
+%{_libdir}/rabbitmq_server-%{main_version}/
+%{_mandir}/man1/rabbitmq-multi.1.gz
+%{_mandir}/man1/rabbitmq-server.1.gz
+%{_mandir}/man1/rabbitmqctl.1.gz
+%{_mandir}/man1/rabbitmqctl_real.1.gz
+%{_sbindir}/rabbitmq-multi
+%{_sbindir}/rabbitmq-server
+%{_sbindir}/rabbitmqctl
+%{_sbindir}/rabbitmqctl_real
+/var/lib/rabbitmq/
+/var/log/rabbitmq/
+/etc/rc.d/init.d/rabbitmq-server
+%config(noreplace) /etc/logrotate.d/rabbitmq-server
%clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
%changelog
-* Thu Jul 24 2008 Tony Garnock-Jones <tonyg@lshift.net> 1.4.0
+* Thu Jul 24 2008 Tony Garnock-Jones <tonyg@lshift.net> 1.4.0-1
- New upstream release
-* Mon Mar 3 2008 Adrien Pierard <adrian@lshift.net> 1.3.0
+* Mon Mar 3 2008 Adrien Pierard <adrian@lshift.net> 1.3.0-1
- New upstream release
-* Wed Sep 26 2007 Simon MacMullen <simon@lshift.net> 1.2.0
+* Wed Sep 26 2007 Simon MacMullen <simon@lshift.net> 1.2.0-1
- New upstream release
-* Wed Aug 29 2007 Simon MacMullen <simon@lshift.net> 1.1.1
+* Wed Aug 29 2007 Simon MacMullen <simon@lshift.net> 1.1.1-1
- New upstream release
-* Mon Jul 30 2007 Simon MacMullen <simon@lshift.net> 1.1.0-alpha
+* Mon Jul 30 2007 Simon MacMullen <simon@lshift.net> 1.1.0-1.alpha
- New upstream release
-* Tue Jun 12 2007 Hubert Plociniczak <hubert@lshift.net> hubert-20070607
+* Tue Jun 12 2007 Hubert Plociniczak <hubert@lshift.net> 1.0.0-1.20070607
- Building from source tarball, added starting script, stopping
-* Mon May 21 2007 Hubert Plociniczak <hubert@lshift.net> 1.0.0-alpha
+* Mon May 21 2007 Hubert Plociniczak <hubert@lshift.net> 1.0.0-1.alpha
- Initial build of server library of RabbitMQ package
diff --git a/packaging/debs/Debian/debian/control b/packaging/debs/Debian/debian/control
index df9a330b..bc691bc7 100644
--- a/packaging/debs/Debian/debian/control
+++ b/packaging/debs/Debian/debian/control
@@ -7,7 +7,7 @@ Standards-Version: 3.7.2
Package: rabbitmq-server
Architecture: all
-Depends: erlang-nox, adduser
+Depends: erlang-nox, adduser, logrotate
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/dirs b/packaging/debs/Debian/debian/dirs
index 0b3f55b9..74f86314 100644
--- a/packaging/debs/Debian/debian/dirs
+++ b/packaging/debs/Debian/debian/dirs
@@ -3,4 +3,5 @@ usr/sbin
usr/share/man
var/lib/rabbitmq/mnesia
var/log/rabbitmq
+etc/logrotate.d
diff --git a/packaging/debs/Debian/debian/init.d b/packaging/debs/Debian/debian/init.d
index f3999888..c3c180a8 100644
--- a/packaging/debs/Debian/debian/init.d
+++ b/packaging/debs/Debian/debian/init.d
@@ -5,7 +5,8 @@
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
-# Short-Description: Enable AMQP service provided by RabbitMQ.
+# Description: RabbitMQ broker
+# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@@ -14,6 +15,7 @@ NAME=rabbitmq-server
DESC=rabbitmq-server
USER=rabbitmq
NODE_COUNT=1
+ROTATE_SUFFIX=
test -x $DAEMON || exit 0
@@ -27,7 +29,7 @@ cd /
start_rabbitmq () {
set +e
- su rabbitmq -s /bin/sh -c "$DAEMON start_all ${NODE_COUNT}" > /var/log/rabbitmq/startup.log 2> /var/log/rabbitmq/startup.err
+ su $USER -s /bin/sh -c "$DAEMON start_all ${NODE_COUNT}" > /var/log/rabbitmq/startup.log 2> /var/log/rabbitmq/startup.err
case "$?" in
0)
echo SUCCESS;;
@@ -42,7 +44,7 @@ start_rabbitmq () {
stop_rabbitmq () {
set +e
- su rabbitmq -s /bin/sh -c "$DAEMON stop_all" > /var/log/rabbitmq/shutdown.log 2> /var/log/rabbitmq/shutdown.err
+ su $USER -s /bin/sh -c "$DAEMON stop_all" > /var/log/rabbitmq/shutdown.log 2> /var/log/rabbitmq/shutdown.err
if [ $? != 0 ] ; then
echo FAILED - check /var/log/rabbitmq/shutdown.log, .err
exit 0
@@ -50,6 +52,14 @@ stop_rabbitmq () {
set -e
}
+rotate_logs_rabbitmq() {
+ set +e
+ su $USER -s /bin/sh -c "$DAEMON rotate_logs_all ${ROTATE_SUFFIX}" 2>&1
+ RETVAL=$?
+ set -e
+
+}
+
case "$1" in
start)
echo -n "Starting $DESC: "
@@ -61,6 +71,10 @@ case "$1" in
stop_rabbitmq
echo "$NAME."
;;
+ rotate-logs)
+ echo -n "Rotating log files for $DESC: "
+ rotate_logs_rabbitmq
+ ;;
force-reload|restart)
echo -n "Restarting $DESC: "
stop_rabbitmq
@@ -68,8 +82,7 @@ case "$1" in
echo "$NAME."
;;
*)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|restart|force-reload}" >&2
+ echo "Usage: $0 {start|stop|rotate-logs|restart|force-reload}" >&2
exit 1
;;
esac
diff --git a/packaging/debs/Debian/debian/rabbitmq-server.logrotate b/packaging/debs/Debian/debian/rabbitmq-server.logrotate
new file mode 100644
index 00000000..247635d1
--- /dev/null
+++ b/packaging/debs/Debian/debian/rabbitmq-server.logrotate
@@ -0,0 +1,12 @@
+/var/log/rabbitmq/*.log {
+ weekly
+ missingok
+ rotate 20
+ compress
+ delaycompress
+ notifempty
+ sharedscripts
+ postrotate
+ /etc/init.d/rabbitmq-server rotate-logs
+ endscript
+} \ No newline at end of file
diff --git a/packaging/debs/Debian/debian/rules b/packaging/debs/Debian/debian/rules
index 6edf27c1..39af711c 100644
--- a/packaging/debs/Debian/debian/rules
+++ b/packaging/debs/Debian/debian/rules
@@ -14,5 +14,6 @@ install/rabbitmq-server::
rm $(RABBIT_LIB)/LICENSE*
mv $(DEB_DESTDIR)usr/sbin/rabbitmqctl $(DEB_DESTDIR)usr/sbin/rabbitmqctl_real
cp debian/rabbitmqctl_wrapper $(DEB_DESTDIR)usr/sbin/rabbitmqctl
+ cp debian/rabbitmq-server.logrotate $(DEB_DESTDIR)etc/logrotate.d/rabbitmq-server
cp $(DEB_DESTDIR)usr/share/man/man1/rabbitmqctl.1.gz $(DEB_DESTDIR)usr/share/man/man1/rabbitmqctl_real.1.gz
chmod a+x $(DEB_DESTDIR)usr/sbin/rabbitmqctl
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index a44dd6da..d78be18e 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -39,7 +39,7 @@ CLUSTER_CONFIG_FILE=/etc/default/rabbitmq_cluster.config
## Log rotation
LOGS="${LOG_BASE}/${NODENAME}.log"
SASL_LOGS="${LOG_BASE}/${NODENAME}-sasl.log"
-BACKUP_EXTENSION=".bak"
+BACKUP_EXTENSION=".1"
[ -f "${LOGS}" ] && cat "${LOGS}" >> "${LOGS}${BACKUP_EXTENSION}"
[ -f "${SASL_LOGS}" ] && cat "${SASL_LOGS}" >> "${SASL_LOGS}${BACKUP_EXTENSION}"
diff --git a/scripts/rabbitmq-server.bat b/scripts/rabbitmq-server.bat
index 46f4bd92..a32fe0fc 100644
--- a/scripts/rabbitmq-server.bat
+++ b/scripts/rabbitmq-server.bat
@@ -65,7 +65,7 @@ set LOG_BASE=%RABBITMQ_BASE_UNIX%/log
rem We save the previous logs in their respective backup
rem Log management (rotation, filtering based of size...) is left as an exercice for the user.
-set BACKUP_EXTENSION=.bak
+set BACKUP_EXTENSION=.1
set LOGS="%RABBITMQ_BASE%\log\%NODENAME%.log"
set SASL_LOGS="%RABBITMQ_BASE%\log\%NODENAME%-sasl.log"
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index cd92f1ac..29f12ff7 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -69,8 +69,9 @@ usage() ->
Available commands:
- start_all <NodeCount> - start a local cluster of RabbitMQ nodes.
- stop_all - stops all local RabbitMQ nodes.
+ start_all <NodeCount> - start a local cluster of RabbitMQ nodes.
+ stop_all - stops all local RabbitMQ nodes.
+ rotate_logs_all [Suffix] - rotate logs for all local RabbitMQ nodes.
"),
halt(3).
@@ -89,11 +90,19 @@ action(start_all, [NodeCount], RpcTimeout) ->
action(stop_all, [], RpcTimeout) ->
io:format("Stopping all nodes...~n", []),
- case read_pids_file() of
- [] -> throw(no_nodes_running);
- NodePids -> stop_nodes(NodePids, RpcTimeout),
- delete_pids_file()
- end.
+ call_all_nodes(fun(NodePids) ->
+ stop_nodes(NodePids, RpcTimeout),
+ delete_pids_file() end);
+
+action(rotate_logs_all, [], RpcTimeout) ->
+ action(rotate_logs_all, [""], RpcTimeout);
+
+action(rotate_logs_all, [Suffix], RpcTimeout) ->
+ io:format("Rotating logs for all nodes...~n", []),
+ call_all_nodes(fun(NodePids) ->
+ rotate_logs(NodePids,
+ list_to_binary(Suffix),
+ RpcTimeout) end).
%% PNodePid is the list of PIDs
%% Running is a boolean exhibiting success at some moment
@@ -272,6 +281,21 @@ is_dead(Pid) ->
end
end}]).
+rotate_logs([], _, _) -> ok;
+rotate_logs([{Node, _} | Rest], BinarySuffix, RpcTimeout) ->
+ io:format("Rotating logs for node ~p~n", [Node]),
+ case rpc:call(Node, rabbit, rotate_logs, [BinarySuffix], RpcTimeout) of
+ {badrpc, _} -> io:format("timeout"),
+ throw(rotate_logs_failed);
+ ok -> rotate_logs(Rest, BinarySuffix, RpcTimeout)
+ end.
+
+call_all_nodes(Func) ->
+ case read_pids_file() of
+ [] -> throw(no_nodes_running);
+ NodePids -> Func(NodePids)
+ end.
+
getenv(Var) ->
case os:getenv(Var) of
false -> throw({missing_env_var, Var});