diff --git a/debian/rules b/debian/rules index 2201b4aa8b25bf1ed652014854369f1e74c221a1..7051ecb0d9a84b9f8361efcf9c5d763f29bd739c 100755 --- a/debian/rules +++ b/debian/rules @@ -47,5 +47,7 @@ install/tarantool:: install/tarantool-common:: pod2man -c 'tarantool instances control' \ debian/tarantool_instance.pod > build-area/tarantool_instance.1 + pod2man -c 'tarantool log rotation' \ + debian/tarantool_logrotate.pod > build-area/tarantool_logrotate.1 install -m0755 extra/logger.pl \ debian/tarantool-common/usr/lib/tarantool/logger diff --git a/debian/scripts/tarantool_logrotate b/debian/scripts/tarantool_logrotate new file mode 100755 index 0000000000000000000000000000000000000000..c65201cc16f74910c54d70f85b2843840e8d610d --- /dev/null +++ b/debian/scripts/tarantool_logrotate @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +CLI="/usr/bin/tarantool" +CONFIG_DIR="/var/lib/tarantool/started" +PID_DIR="/var/run/tarantool" + +logger_notify() { + CFG=$1 + PORT_PRIMARY=`grep \ + '^[[:space:]]*primary_port[[:space:]]*=[[:space:]]*[[:digit:]]\+' $CFG \ + | tail -n 1 \ + | sed 's/[^[:digit:]]//g' + ` + PORT_ADMIN=`grep \ + '^[[:space:]]*admin_port[[:space:]]*=[[:space:]]*[[:digit:]]\+' $CFG \ + | tail -n 1 \ + | sed 's/[^[:digit:]]//g' + ` + LOGGER_PID=`${CLI} p $PORT_PRIMARY -m $PORT_ADMIN "show info" \ + | grep 'logger_pid:' \ + | sed 's/[^[:digit:]]//g' + ` + kill -USR2 $LOGGER_PID +} + +if test -d ${PID_DIR}; then + for file in `ls -1 $PID_DIR`; do + INSTANCE=`basename $file .pid` + logger_notify "$CONFIG_DIR/$INSTANCE.cfg" + done +fi diff --git a/debian/tarantool-common.install b/debian/tarantool-common.install index a3d438549436f5803aa80cc9f7afb9d00f64af49..1ca973ef53295b9405705214720e469882c8094f 100644 --- a/debian/tarantool-common.install +++ b/debian/tarantool-common.install @@ -1,2 +1,3 @@ debian/etc/example.cfg /etc/tarantool/instances.available/ debian/scripts/tarantool_instance /usr/sbin +debian/scripts/tarantool_rotate /usr/sbin diff --git a/debian/tarantool-common.logrotate b/debian/tarantool-common.logrotate index 07ed66df942aa21f6b3cbee8a2d36de101108980..b9c81f51cb56ce7bf51dd39bfd1a322bfabc324d 100644 --- a/debian/tarantool-common.logrotate +++ b/debian/tarantool-common.logrotate @@ -7,10 +7,6 @@ delaycompress create 0640 tarantool adm postrotate - if test -d /var/run/tarantool; then - if [ `ls /var/run/tarantool | wc -l` -gt 0 ]; then - kill -USR2 `cat /var/run/tarantool/*.pid` - fi - fi + /usr/sbin/tarantool_rotate endscript } diff --git a/debian/tarantool_logrotate.pod b/debian/tarantool_logrotate.pod new file mode 100644 index 0000000000000000000000000000000000000000..1248621bb9d9dede25a23f99669397307e05025f --- /dev/null +++ b/debian/tarantool_logrotate.pod @@ -0,0 +1,15 @@ +=head1 NAME + +tarantool_logrotate - utility to rotate tarantool instances logs + + +=head1 SINOPSYS + + tarantool_logrotate + + +=head1 DESCRIPTION + +The utility tries to connect to each running tarantool instance to get +logger pid file, then it sends SIGUSR2 to logger which initiates +log rotataion procedure. diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 7cd20680032d2c95a771ceda97a09fbd4b47ca3e..765d4a7466e744f23d2169b3146ec9942fb4d319 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,4 +1,3 @@ - add_custom_target(man ALL COMMAND ${POD2MAN} -c 'high performance key/value storage server' ${CMAKE_SOURCE_DIR}/doc/man/tarantool_box.pod > ${PROJECT_BINARY_DIR}/doc/man/tarantool_box.1