From 4a4f57cca8293944e7fa0f84386b06b855ad4ae1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 31 Oct 2012 14:53:02 -0400 Subject: [PATCH] Bug 8519 - Make koha-index-daemon run on startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [This patch was split out from tcohen's excellent patches for bug 8519 --jcamins 2012/10/31] Added a new koha-index-daemon-ctl.sh script that uses the 'koha-index-daemon' provided by Koha::Contrib::Tamil (install via CPAN) to process the indexing queue ('zebraqueue' for now, 'indexqueue' in the future I guess :-P). This script could be easily modified in the future for using another index queue processing script (a more abstract indexing script for both Solr and Zebra, etc). I removed all zebra-ish stuff from it. Documentation patches will be provided as followups, once Mark Tompsett's docs are pushed to avoid continous rebasing. Tested to work on an up-to-date Ubuntu 12.04. Sponsored-by: Universidad Nacional de Córdoba Signed-off-by: wajasu Signed-off-by: Jared Camins-Esakov --- Makefile.PL | 1 + install_misc/install_koha_on_fresh_debian | 2 + misc/bin/koha-index-daemon-ctl.sh | 86 +++++++++++++++++++++++++++++ t/Makefile | 2 +- t/db_dependent/lib/KohaTest.pm | 4 +- 5 files changed, 92 insertions(+), 3 deletions(-) create mode 100755 misc/bin/koha-index-daemon-ctl.sh diff --git a/Makefile.PL b/Makefile.PL index ca9e4f0..6c6e186 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -523,6 +523,7 @@ if ($config{'INSTALL_ZEBRA'} eq "yes") { push @{ $pl_files->{'rewrite-config.PL'} }, ( 'blib/SCRIPT_DIR/koha-zebra-ctl.sh', 'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh', + 'blib/SCRIPT_DIR/koha-index-daemon-ctl.sh', ); if ($config{'INSTALL_PAZPAR2'} eq 'yes') { push @{ $pl_files->{'rewrite-config.PL'} }, ( diff --git a/install_misc/install_koha_on_fresh_debian b/install_misc/install_koha_on_fresh_debian index 50e2728..fdfbaef 100644 --- a/install_misc/install_koha_on_fresh_debian +++ b/install_misc/install_koha_on_fresh_debian @@ -523,6 +523,8 @@ a2ensite koha invoke-rc.d apache2 reload koha_script=`makefile_value KOHA_DEST_SCRIPT_DIR` +ln -s "$koha_script"/koha-index-daemon-ctl.sh /etc/init.d/koha-index-daemon +update-rc.d koha-index-daemon defaults # TODO: # - add translator diff --git a/misc/bin/koha-index-daemon-ctl.sh b/misc/bin/koha-index-daemon-ctl.sh new file mode 100755 index 0000000..03cdca8 --- /dev/null +++ b/misc/bin/koha-index-daemon-ctl.sh @@ -0,0 +1,86 @@ +#!/bin/sh + +# This file is part of Koha. +# +# Koha 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 2 of the License, or (at your option) any later +# version. +# +# Koha 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 +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +### BEGIN INIT INFO +# Provides: koha-index-daemon-$DBNAME +# Required-Start: $local_fs $syslog +# Required-Stop: $local_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# X-Interactive: false +# Short-Description: Start/stop koha-index-daemon for $DBNAME +### END INIT INFO + +. /lib/lsb/init-functions + +USER=__KOHA_USER__ +GROUP=__KOHA_GROUP__ +DBNAME=__DB_NAME__ +NAME=koha-index-daemon-$DBNAME +LOGDIR=__LOG_DIR__ +PERL5LIB=__PERL_MODULE_DIR__ +KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml +ERRLOG=$LOGDIR/koha-index-daemon.err +STDOUT=$LOGDIR/koha-index-daemon.log +OUTPUT=$LOGDIR/koha-index-daemon-output.log + +export KOHA_CONF +export PERL5LIB + +INDEXDAEMON="koha-index-daemon" +INDEXDAEMON_OPTS="--timeout 30 --conf $KOHA_CONF \ + --directory /var/tmp/koha-index-daemon-$DBNAME" + +DAEMONOPTS="--name=$NAME \ + --errlog=$ERRLOG \ + --stdout=$STDOUT \ + --output=$OUTPUT \ + --verbose=1 --respawn --delay=30" + +USER="--user=$USER.$GROUP" + + +case "$1" in + start) + log_daemon_msg "Starting Koha indexing daemon ($DBNAME)" + if daemon $DAEMONOPTS $USER -- $INDEXDAEMON $INDEXDAEMON_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping Koha indexing daemon ($DBNAME)" + if daemon $DAEMONOPTS $USER --stop -- $INDEXDAEMON $INDEXDAEMON_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + restart) + log_daemon_msg "Restarting the Koha indexing daemon ($DBNAME)" + if daemon $DAEMONOPTS $USER --restart -- $INDEXDAEMON $INDEXDAEMON_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi + ;; + *) + log_success_msg "Usage: /etc/init.d/$NAME {start|stop|restart}" + exit 1 + ;; +esac diff --git a/t/Makefile b/t/Makefile index 80058bb..5a4a5b1 100644 --- a/t/Makefile +++ b/t/Makefile @@ -29,7 +29,7 @@ REAL_REWRITE_SCRIPT = ../rewrite-config.PL ZEBRA_CONF_DIR = run/etc/zebradb ZEBRA_CONF_FILES = $(ZEBRA_CONF_DIR)/etc/passwd $(ZEBRA_CONF_DIR)/zebra-biblios.cfg $(ZEBRA_CONF_DIR)/zebra-authorities.cfg $(ZEBRA_CONF_DIR)/zebra-authorities-dom.cfg $(ZEBRA_CONF_DIR)/explain-authorities.xml $(ZEBRA_CONF_DIR)/explain-biblios.xml $(ZEBRA_CONF_DIR)/retrieval-info-auth-grs1.xml $(ZEBRA_CONF_DIR)/retrieval-info-auth-dom.xml $(ZEBRA_CONF_DIR)/ccl.properties $(ZEBRA_CONF_DIR)/cql.properties $(ZEBRA_CONF_DIR)/pqf.properties -SCRIPTS = koha-zebra-ctl.sh koha-pazpar2-ctl.sh +SCRIPTS = koha-zebra-ctl.sh koha-pazpar2-ctl.sh koha-index-daemon-ctl.sh SRC_SCRIPT_DIR = ../misc/bin TEST_SCRIPT_DIR = run/bin diff --git a/t/db_dependent/lib/KohaTest.pm b/t/db_dependent/lib/KohaTest.pm index 601c48f..f69e1cb 100644 --- a/t/db_dependent/lib/KohaTest.pm +++ b/t/db_dependent/lib/KohaTest.pm @@ -818,7 +818,7 @@ sub stop_zebrasrv { sub start_zebraqueue_daemon { - my $command = q(echo "zebraqueue_daemon is deprecated"); + my $command = q(run/bin/koha-index-daemon-ctl.sh start); diag $command; my $started = system( $command ); diag "started: $started"; @@ -832,7 +832,7 @@ sub start_zebraqueue_daemon { sub stop_zebraqueue_daemon { - my $command = q(echo "zebraqueue_daemon is deprecated"); + my $command = q(run/bin/koha-index-daemon-ctl.sh stop); diag $command; my $started = system( $command ); diag "started: $started"; -- 1.7.9.5