Tomas Cohen Arazi
eed7f263d0
Short: Launch an indexing daemon (rebuild_zebra.pl -daemon) process for each enabled instance. Enabling/disabling the use of the indexer is handled by global configuration variables in /etc/default/koha-common. Also provides command line tools to manage the running indexer daemons for your instances. Long: Using an indexing daemon avoids launching a new interpreter each time the cron triggers the indexing, and also allows sub-minute incremental reindexing, a requirement from our librarians.[1] Using the indexer daemon could remain "experimental" until it gets more testing; so is disabled by default initially. To enable the use of the indexer the user has to tweak the /etc/default/koha-common config file. Specifically the USE_INDEXER_DAEMON variable, which is clearly explained in the file. Frecquency defaults to 5 sec, and can be changed by tweaking the /etc/default/koha-common config file too. This patch uses rebuild_zebra.pl in daemon mode, but it is crafted to allow changing the indexing daemon and passing specific option switches it might need. Regards To+ [1] This is the .deb version of http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8519 Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
202 lines
4.4 KiB
Bash
Executable file
202 lines
4.4 KiB
Bash
Executable file
#! /bin/sh
|
|
### BEGIN INIT INFO
|
|
# Provides: koha-common
|
|
# Required-Start: $remote_fs
|
|
# Required-Stop: $remote_fs
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Start Zebra server for each Koha instance
|
|
# Description: For each enabled Koha instance on this host,
|
|
# as listed by "koha-list --enabled", start a Zebra
|
|
# server (using koha-start-zebra).
|
|
### END INIT INFO
|
|
|
|
# Author: Lars Wirzenius <lars@catalyst.net.nz>
|
|
|
|
# Do NOT "set -e"
|
|
|
|
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
|
DESC="Koha ILS"
|
|
NAME="koha-common"
|
|
SCRIPTNAME=/etc/init.d/$NAME
|
|
|
|
# Exit if the package is not installed
|
|
[ -x /usr/sbin/koha-start-zebra ] || exit 0
|
|
|
|
# Read configuration variable file if it is present
|
|
if [ -r /etc/default/$NAME ]; then
|
|
# Debian / Ubuntu
|
|
. /etc/default/$NAME
|
|
elif [ -r /etc/sysconfig/$NAME ]; then
|
|
# RedHat / SuSE
|
|
. /etc/sysconfig/$NAME
|
|
fi
|
|
|
|
# Load the VERBOSE setting and other rcS variables
|
|
. /lib/init/vars.sh
|
|
|
|
# Define LSB log_* functions.
|
|
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
|
. /lib/lsb/init-functions
|
|
|
|
#
|
|
# Function that starts the daemon/service
|
|
#
|
|
do_start()
|
|
{
|
|
# We insure all required directories exist, including disabled ones.
|
|
koha-create-dirs $(koha-list)
|
|
koha-start-zebra $(koha-list --enabled)
|
|
koha-start-sip $(koha-list --enabled)
|
|
|
|
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
|
|
koha-indexer --start --quiet $(koha-list --enabled)
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Function that stops the daemon/service
|
|
#
|
|
do_stop()
|
|
{
|
|
# We stop everything, including disabled ones.
|
|
koha-stop-zebra $(koha-list) || true
|
|
koha-stop-sip $(koha-list) || true
|
|
|
|
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
|
|
koha-indexer --stop --quiet $(koha-list --enabled)
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Function that sends a SIGHUP to the daemon/service
|
|
#
|
|
do_reload() {
|
|
koha-restart-zebra $(koha-list --enabled)
|
|
koha-stop-sip $(koha-list) || true
|
|
koha-start-sip $(koha-list --enabled)
|
|
|
|
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
|
|
koha-indexer --restart --quiet $(koha-list --enabled)
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Function that checks zebrasrv is running for the specified instance
|
|
#
|
|
is_zebra_running()
|
|
{
|
|
local instancename=$1
|
|
|
|
if daemon --name="$instancename-koha-zebra" \
|
|
--user="$instancename-koha.$instancename-koha" \
|
|
--running ; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Function that checks SIP server is running for the specified instance
|
|
#
|
|
is_sip_running()
|
|
{
|
|
local instancename=$1
|
|
|
|
if daemon --name="$instancename-koha-sip" \
|
|
--pidfiles="/var/run/koha/$instancename" \
|
|
--user="$instancename-koha.$instancename-koha" \
|
|
--running ; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Function that shows the status of the zebrasrv daemon for
|
|
# enabled instances
|
|
#
|
|
zebra_status()
|
|
{
|
|
for instance in $(koha-list --enabled); do
|
|
|
|
log_daemon_msg "Zebra server running for instace $instance"
|
|
|
|
if is_zebra_running $instance ; then
|
|
log_end_msg 0
|
|
else
|
|
log_end_msg 1
|
|
fi
|
|
done
|
|
}
|
|
|
|
#
|
|
# Function that shows the status of the SIP server daemon for
|
|
# enabled instances
|
|
#
|
|
sip_status()
|
|
{
|
|
for instance in $(koha-list --enabled --sip); do
|
|
|
|
log_daemon_msg "SIP server running for instace $instance"
|
|
|
|
if is_sip_running $instance ; then
|
|
log_end_msg 0
|
|
else
|
|
log_end_msg 1
|
|
fi
|
|
done
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
|
do_start
|
|
case "$?" in
|
|
0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
|
*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
|
esac
|
|
;;
|
|
stop)
|
|
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
|
do_stop
|
|
case "$?" in
|
|
0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
|
*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
|
esac
|
|
;;
|
|
restart|force-reload)
|
|
#
|
|
# If the "reload" option is implemented then remove the
|
|
# 'force-reload' alias
|
|
#
|
|
log_daemon_msg "Restarting $DESC" "$NAME"
|
|
do_stop
|
|
case "$?" in
|
|
0)
|
|
do_start
|
|
case "$?" in
|
|
0) log_end_msg 0 ;;
|
|
*) log_end_msg 1 ;; # Failed to start
|
|
esac
|
|
;;
|
|
*)
|
|
# Failed to stop
|
|
log_end_msg 1
|
|
;;
|
|
esac
|
|
;;
|
|
status)
|
|
zebra_status
|
|
sip_status
|
|
;;
|
|
*)
|
|
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
|
|
exit 3
|
|
;;
|
|
esac
|
|
|
|
:
|