Koha/debian/scripts/koha-stop-zebra
Mark Tompsett ac4a058b05 Bug 16885: koha-stop-zebra should be more sure of stopping zebrasrv
This patch follows Galen's suggestion in comment #7.

TEST PLAN
---------
1) Back up your koha logs as desired.
2) add something to /var/log/koha/{instance name}/intranet-error.log
3) ps aux | grep zebra
4) logrotate -f /etc/logrotate.d/koha-common
5) ps aux | grep zebra
   -- the zebrasrv and daemon process for zebra indexing
      didn't restart.
6) apply this patch against /usr/sbin/koha-stop-zebra
7) sudo koha-start-zebra {instance name}
8) ps aux | grep zebra
   -- the processes should have started up again.
9) add different junk to /var/log/koha/{instance name}/intranet-error.log
10) ps aux | grep zebra
11) logrotate -f /etc/logrotate.d/koha-common
12) ps aux | grep zebra
    -- the process ids for the zebrasrv and daemon processes should
       be different, but the number of processes is the same as before.
13) sign off, because its less ugly than comment #3

Sponsored-by: Tulong Aklatan

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Works as expected, no regressions found.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-08-17 17:57:15 +00:00

74 lines
1.9 KiB
Bash
Executable file

#!/bin/sh
#
# koha-stop-zebra - Stop Zebra for named Koha instances
# Copyright 2010 Catalyst IT, Ltd
#
# 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 <http://www.gnu.org/licenses/>.
set -e
# include helper functions
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
. "/usr/share/koha/bin/koha-functions.sh"
else
echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
exit 1
fi
stop_zebra_instance()
{
local instancename=$1
local PIDFILE="/var/run/koha/${instancename}/${instancename}-koha-zebra.pid"
echo "Stopping Zebra server for $instancename"
if start-stop-daemon --pidfile ${PIDFILE} --stop --quiet --retry=TERM/30/KILL/5; then
return 0;
else
return 1;
fi
}
usage()
{
local scriptname=$0
cat <<EOF
Stops Zebra for Koha instances.
Usage: $scriptname instancename1 instancename2...
EOF
}
# Parse command line.
#[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
# Loop through the instance names
for name in "$@"
do
if is_instance $name ; then
if is_zebra_running $name; then
if ! stop_zebra_instance $name; then
warn "Something went wrong stopping Zebra for $name."
fi
else
warn "Zebra already stopped for instance $name."
fi
else
warn "Unknown instance $name."
fi
done
exit 0