From dcb3858ffd6e9e2f6b3d0219fe9ed338fc3b29a1 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Sat, 22 Dec 2007 19:25:50 -0500 Subject: [PATCH] Several important commits: * adding zebra daemons for managing server and queue processes * improvements to the README.debian file * Fixes to Search.pm since last series of commits broke zebra-based searching (again) * moving some files to new misc/bin and misc/cronjobs Signed-off-by: Joshua Ferraro --- C4/Search.pm | 11 ++--- README.debian | 41 +++++++++++++++---- .../data/mysql/en/mandatory/sysprefs.sql | 2 +- misc/bin/koha-zebra-ctl.sh | 32 +++++++++++++++ misc/bin/koha-zebraqueue-ctl.sh | 35 ++++++++++++++++ misc/{ => bin}/zebraqueue_daemon.pl | 0 misc/{ => cronjobs}/backup.sh | 0 7 files changed, 107 insertions(+), 14 deletions(-) create mode 100755 misc/bin/koha-zebra-ctl.sh create mode 100755 misc/bin/koha-zebraqueue-ctl.sh rename misc/{ => bin}/zebraqueue_daemon.pl (100%) rename misc/{ => cronjobs}/backup.sh (100%) diff --git a/C4/Search.pm b/C4/Search.pm index 12ba39596f..c4ee370571 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -402,6 +402,7 @@ sub getRecords { while ( ( my $i = ZOOM::event( \@zconns ) ) != 0 ) { my $ev = $zconns[ $i - 1 ]->last_event(); if ( $ev == ZOOM::Event::ZEND ) { + next unless $results[ $i - 1 ]; my $size = $results[ $i - 1 ]->size(); if ( $size > 0 ) { my $results_hash; @@ -660,8 +661,8 @@ sub _build_weighted_query { $weighted_query .= " or ti,phr,r3=\"$operand\""; # phrase title #$weighted_query .= " or any,ext,r4=$operand"; # exact any #$weighted_query .=" or kw,wrdl,r5=\"$operand\""; # word list any - $weighted_query .= " or wrd,fuzzy,r8=\"$operand\"" if $fuzzy_enabled; # add fuzzy, word list - $weighted_query .= " or wrd,right-Truncation,r9=\"$stemmed_operand\"" if ($stemming and $stemmed_operand); # add stemming, right truncation + $weighted_query .= " or wrdl,fuzzy,r8=\"$operand\"" if $fuzzy_enabled; # add fuzzy, word list + $weighted_query .= " or wrdl,right-Truncation,r9=\"$stemmed_operand\"" if ($stemming and $stemmed_operand); # add stemming, right truncation # embedded sorting: 0 a-z; 1 z-a # $weighted_query .= ") or (sort1,aut=1"; } @@ -890,10 +891,10 @@ sub buildQuery { if ($group_OR_limits) { $limit.=" and " if ($query || $limit ); $limit.="($group_OR_limits)"; - } + } if ($availability_limit) { - $limit.=" not " if ($query || $limit ); - $limit.="$availability_limit"; + $limit.=" and " if ($query || $limit ); + $limit.="($availability_limit)"; } # normalize the strings $query =~ s/:/=/g; diff --git a/README.debian b/README.debian index 1ebd7c2e84..15da92647c 100644 --- a/README.debian +++ b/README.debian @@ -5,7 +5,7 @@ Installation Guide for Installing Koha on Debian Etch with MySQL 5 Copyright (C) 2007, LibLime Maintainer: Joshua Ferraro (jmf AT liblime DOT com) -Feedback/bug reports: jmf@liblime.com +Feedback/bug reports: jmf AT liblime DOT com This document last modified: 22 December 2007 Installation Instructions @@ -151,16 +151,41 @@ When the configuration is completed CPAN will install the Perl modules. $ sudo a2enmod rewrite $ sudo a2ensite koha && /etc/init.d/apache2 reload -5. start Zebra, reload Apache2 config +5. Configure and start Zebra - $ sudo su - $ zebrasrv -f /etc/koha/koha-conf.xml +Note: it's recommended that you daemonize the Zebra process and add it to your +startup profile. For a non-production test/development installation, running +Zebra from the command line can be useful. Pick from the two available options +below, or roll your own :-) + +Note: it's also recommended that you create a Koha system user, which you will +have specified during the install process. Alternatively, Zebra can be +configured to run as the root user. + +Option 1: run the Zebra processes from the command line: + + Zebra Server: + $ sudo ${KOHA_USER} zebrasrv -f /etc/koha/koha-conf.xml (note that the path to koha-conf.xml may be different depending on your installation choices) -Note: it's recommended that you daemonize the Zebra process and add it to your -startup profile. For a non-production test/development installation, running -Zebra from the command line can be useful. + Zebraqueue Daemon: + $ sudo ${KOHA_USER} misc/bin/zebraqueue_daemon.pl + +Option 2: run the Zebra processes as daemons, and add to startup process: + + Zebra Server: + $ sudo ln -s misc/bin/koha-zebra-ctl.sh /etc/init.d/koha-zebra-daemon + $ update-rc.d koha-zebra-daemon defaults + ( Note: see man chkconfig(8) on other distros ) + $ misc/bin/koha-zebra-ctl.sh start + + Zebraqueue Daemon: + $ sudo ln -s misc/bin/koha-zebraqueue-ctl.sh /etc/init.d/koha-zebraqueue-daemon + $ update-rc.d koha-zebraqueue-daemon defaults + ( Note: see man chkconfig(8) on other distros ) + + $ misc/bin/koha-zebraqueue-ctl.sh start 6. Run the Web Installer, populate the database, initial configuration of settings @@ -181,7 +206,7 @@ Tested on the following operating environments Installer Bug reports ===================== -Please send any installer bug reports to jmf@liblime.com +Please send any installer bug reports to jmf AT liblime DOT com Other Notes ===================== diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 5ba06ee261..35025b908b 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -110,7 +110,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SessionStorage','mysql','Use database or a temporary file for storing session data','mysql|Pg|tmp','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('CircAutocompl','1','If ON, autocompletion is enabled for the Circulation input',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('RoutingSerials','1','If ON, serials routing is enabled',NULL,'YesNo'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SearchMyLibraryFirst','1','If ON, OPAC searches return results limited by the user\'s library by default if they are logged in',NULL,'YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SearchMyLibraryFirst','0','If ON, OPAC searches return results limited by the user\'s library by default if they are logged in',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('dontmerge','1','If ON, modifying an authority record will not update all associated bibliographic records immediately, ask your system administrator to enable the merge_authotities.pl cron job',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BiblioAddsAuthorities','0','If ON, adding a new biblio will check for an existing authority record and create one on the fly if one doesn\'t exist',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('QueryStemming','1','If ON, enables query stemming',NULL,'YesNo'); diff --git a/misc/bin/koha-zebra-ctl.sh b/misc/bin/koha-zebra-ctl.sh new file mode 100755 index 0000000000..cc284c30ff --- /dev/null +++ b/misc/bin/koha-zebra-ctl.sh @@ -0,0 +1,32 @@ +#!/bin/bash +USER=__KOHA_USER__ +GROUP=__KOHA_GROUP__ +NAME=koha-zebra-ctl +LOGDIR=__LOG_DIR__ +ERRLOG=$LOGDIR/koha-zebradaemon.err +STDOUT=$LOGDIR/koha-zebradaemon.log +OUTPUT=$LOGDIR/koha-zebradaemon-output.log +KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml +# you may need to change this depending on where zebrasrv is installed +ZEBRASRV=/usr/bin/zebrasrv + +test -f $ZEBRASRV || exit 0 + +case "$1" in + start) + echo "Starting Zebra Server" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP -- $ZEBRASRV -f $KOHA_CONF + ;; + stop) + echo "Stopping Zebra Server" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --stop -- $ZEBRASRV -f $KOHA_CONF + ;; + restart) + echo "Restarting the Zebra Server" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --restart -- $ZEBRASRV -f $KOHA_CONF + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart}" + exit 1 + ;; +esac diff --git a/misc/bin/koha-zebraqueue-ctl.sh b/misc/bin/koha-zebraqueue-ctl.sh new file mode 100755 index 0000000000..f1dff6689b --- /dev/null +++ b/misc/bin/koha-zebraqueue-ctl.sh @@ -0,0 +1,35 @@ +#!/bin/bash +USER=__KOHA_USER__ +GROUP=__KOHA_GROUP__ +NAME=koha-zebraqueue-ctl +LOGDIR=__LOG_DIR__ +PERL5LIB=__PERL_MODULE_DIR__ +KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml +ERRLOG=$LOGDIR/koha-zebraqueue.err +STDOUT=$LOGDIR/koha-zebraqueue.log +OUTPUT=$LOGDIR/koha-zebraqueue-output.log +KOHA_CONF=/home/jmf/koha-dev/etc/koha-conf.xml +export KOHA_CONF +export PERL5LIB +ZEBRAQUEUE=__PERL_MODULE_DIR__/misc/bin/zebraqueue_daemon.pl + +test -f $ZEBRAQUEUE || exit 0 + +case "$1" in + start) + echo "Starting Zebraqueue Daemon" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF + ;; + stop) + echo "Stopping Zebraqueue Daemon" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --stop -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF + ;; + restart) + echo "Restarting the Zebraqueue Daemon" + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --restart -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart}" + exit 1 + ;; +esac diff --git a/misc/zebraqueue_daemon.pl b/misc/bin/zebraqueue_daemon.pl similarity index 100% rename from misc/zebraqueue_daemon.pl rename to misc/bin/zebraqueue_daemon.pl diff --git a/misc/backup.sh b/misc/cronjobs/backup.sh similarity index 100% rename from misc/backup.sh rename to misc/cronjobs/backup.sh -- 2.39.5