From 980b6fb3cb239aa658b89f87b6674b531aeb10e4 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 14 Sep 2012 15:26:12 -0300 Subject: [PATCH] Bug 8773 - Start per-instance koha-index-daemon in .deb setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" This bug is the .deb version of 8519 [1]. It is motivated by the fact that using 1-minute (or more) frecquency cronjobs to do the incremental indexing of records does not scale for us, nor is accepted by our librarians. Using an indexing daemon avoids launching a new interpreter each time the cron triggers the indexing, and also allows sub-minute reindexing. Frecquency is hardcoded right now. A follow up could provide a way to set it for each instance. This patch relies on Koha::Contrib::Tamil's koha-index-daemon script [2], but could be easily adjusted to use another if we got a new one (SolR?). I havent got the time to setup my infrastructure to generate my own debs, and thus haven't got the oportunity to test this patch. If anyone with the skills helps me on setting that I could test them and fix possible issues. If there's something I could change to make this patches better just let me know. Regards To+ [1] http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8519 [2] The default cronjob that is set using the debian/koha-common.cron.d file is being disbaled by this patch to avoid collision. Sponsored-by: Universidad Nacional de Córdoba --- debian/koha-common.cron.d | 2 +- debian/koha-common.init | 3 +++ debian/scripts/koha-restart-indexer | 50 +++++++++++++++++++++++++++++++++++ debian/scripts/koha-start-indexer | 50 +++++++++++++++++++++++++++++++++++ debian/scripts/koha-stop-indexer | 50 +++++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 1 deletion(-) create mode 100755 debian/scripts/koha-restart-indexer create mode 100755 debian/scripts/koha-start-indexer create mode 100755 debian/scripts/koha-stop-indexer diff --git a/debian/koha-common.cron.d b/debian/koha-common.cron.d index cd7f3c2..c7fc94e 100644 --- a/debian/koha-common.cron.d +++ b/debian/koha-common.cron.d @@ -6,5 +6,5 @@ SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra $(koha-list --enabled) +# */5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra $(koha-list --enabled) */15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl diff --git a/debian/koha-common.init b/debian/koha-common.init index 5be77d3..7946785 100755 --- a/debian/koha-common.init +++ b/debian/koha-common.init @@ -45,6 +45,7 @@ do_start() # We insure all required directories exist, including disabled ones. koha-create-dirs $(koha-list) koha-start-zebra $(koha-list --enabled) + koha-start-indexer $(koha-list --enabled) } # @@ -54,6 +55,7 @@ do_stop() { # We stop everything, including disabled ones. koha-stop-zebra $(koha-list) || true + koha-stop-indexer $(koha-list --enabled) } # @@ -61,6 +63,7 @@ do_stop() # do_reload() { koha-restart-zebra $(koha-list --enabled) + koha-restart-indexer $(koha-list --enabled) } case "$1" in diff --git a/debian/scripts/koha-restart-indexer b/debian/scripts/koha-restart-indexer new file mode 100755 index 0000000..7030b92 --- /dev/null +++ b/debian/scripts/koha-restart-indexer @@ -0,0 +1,50 @@ +#!/bin/sh +# +# koha-restart-indexer -- Restart Indexer Daemon for named Koha instandes +# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +. /lib/lsb/init-functions + +INDEXDAEMON="koha-index-daemon" +PERL5LIB="/usr/share/koha/lib" + +for name in "$@" +do + + KOHA_CONF="/etc/koha/sites/$name/koha-conf.xm" + + INDEXDAEMON_OPTS="--timeout 30 \ + --conf $KOHA_CONF \ + --directory /var/tmp/koha-indexer-daemon-$name" + + DAEMONOPTS="--name=$name-koha-indexer \ + --errlog=/var/log/koha/$name/koha-indexer-error.log \ + --stdout=/var/log/koha/$name/koha-indexer.log \ + --output=/var/log/koha/$name/koha-indexer-output.log \ + --verbose=1 --respawn --delay=30 \ + --user=$name-koha.$name-koha" + + log_daemon_msg "Restarting Koha indexing daemon for $name" + + if daemon $DAEMONOPTS --restart -- $INDEXDAEMON $INDEXDAEMON_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi + +done diff --git a/debian/scripts/koha-start-indexer b/debian/scripts/koha-start-indexer new file mode 100755 index 0000000..7ab7a02 --- /dev/null +++ b/debian/scripts/koha-start-indexer @@ -0,0 +1,50 @@ +#!/bin/sh +# +# koha-start-indexer -- Start Indexer Daemon for named Koha instandes +# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +. /lib/lsb/init-functions + +INDEXDAEMON="koha-index-daemon" +PERL5LIB="/usr/share/koha/lib" + +for name in "$@" +do + + KOHA_CONF="/etc/koha/sites/$name/koha-conf.xm" + + INDEXDAEMON_OPTS="--timeout 30 \ + --conf $KOHA_CONF \ + --directory /var/tmp/koha-indexer-daemon-$name" + + DAEMONOPTS="--name=$name-koha-indexer \ + --errlog=/var/log/koha/$name/koha-indexer-error.log \ + --stdout=/var/log/koha/$name/koha-indexer.log \ + --output=/var/log/koha/$name/koha-indexer-output.log \ + --verbose=1 --respawn --delay=30 \ + --user=$name-koha.$name-koha" + + log_daemon_msg "Starting Koha indexing daemon for $name" + + if daemon $DAEMONOPTS -- $INDEXDAEMON $INDEXDAEMON_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi + +done diff --git a/debian/scripts/koha-stop-indexer b/debian/scripts/koha-stop-indexer new file mode 100755 index 0000000..accb967 --- /dev/null +++ b/debian/scripts/koha-stop-indexer @@ -0,0 +1,50 @@ +#!/bin/sh +# +# koha-stop-indexer -- Stop Indexer Daemon for named Koha instandes +# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +. /lib/lsb/init-functions + +INDEXDAEMON="koha-index-daemon" +PERL5LIB="/usr/share/koha/lib" + +for name in "$@" +do + + KOHA_CONF="/etc/koha/sites/$name/koha-conf.xm" + + INDEXDAEMON_OPTS="--timeout 30 \ + --conf $KOHA_CONF \ + --directory /var/tmp/koha-indexer-daemon-$name" + + DAEMONOPTS="--name=$name-koha-indexer \ + --errlog=/var/log/koha/$name/koha-indexer-error.log \ + --stdout=/var/log/koha/$name/koha-indexer.log \ + --output=/var/log/koha/$name/koha-indexer-output.log \ + --verbose=1 --respawn --delay=30 \ + --user=$name-koha.$name-koha" + + log_daemon_msg "Stopping Koha indexing daemon for $name" + + if daemon $DAEMONOPTS --stop -- $INDEXDAEMON $INDEXDAEMON_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi + +done -- 1.7.9.5