From ac69592f5bbe89df1fa491f9faace61727b8385a Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 2 Aug 2016 23:26:03 -0400 Subject: [PATCH] Bug 16885: koha-stop-zebra should be more sure of stopping zebrasrv This patch actually loops 10 tens to check, before giving up. 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 --- debian/scripts/koha-stop-zebra | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/debian/scripts/koha-stop-zebra b/debian/scripts/koha-stop-zebra index a584ca1..57d093f 100755 --- a/debian/scripts/koha-stop-zebra +++ b/debian/scripts/koha-stop-zebra @@ -31,15 +31,42 @@ stop_zebra_instance() local instancename=$1 echo "Stopping Zebra server for $instancename" + + # both daemon and zebrasrv processes for one instance + # will go away, but there could be other processes + # for other instances. + expecting=`ps aux | grep zebra | wc -l` + expecting=$((expecting-2)) + + # Issue command to stop the zebra server daemon \ --name="$instancename-koha-zebra" \ --pidfiles="/var/run/koha/$instancename/" \ --user="$instancename-koha.$instancename-koha" \ --stop \ -- \ - zebrasrv \ - return 0 || \ + zebrasrv + + # If it doesn't return nicely, return 1 for bad. + if [ $? -ne 0 ]; then return 1 + fi + + # Now actually wait a bit. But not forever. + count=0 + check=$((expecting+2)) + while ( [ $count -lt 10 ] && [ $check -gt $expecting ] ); do + count=$((count+1)) + # Recount the zebra related processes + check=`ps aux | grep zebra | wc -l` + done + + # return 1 for 10 loops of not stopped yet. + if [ $check -ne $expecting ]; then + return 1 + else + return 0 + fi } usage() -- 2.1.4