[Koha-patches] [PATCH] Bug 8773 - Start per-instance koha-index-daemon in .deb setup

Tomas Cohen Arazi tomascohen at gmail.com
Tue Sep 18 00:37:48 CEST 2012


This bug is the .deb version of 8519 [1]. It is motivated by the fact that
using 1-minute (or more) frecquency cronjobs to do the incremental
indexing of records does not scale for us, nor is accepted by our
librarians.

Using an indexing daemon avoids launching a new interpreter each time
the cron triggers the indexing, and also allows sub-minute reindexing.
Frecquency is hardcoded right now. A follow up could provide a way
to set it for each instance.

This patch relies on Koha::Contrib::Tamil's koha-index-daemon script [2],
but could be easily adjusted to use another if we got a new one (SolR?).

I havent got the time to setup my infrastructure to generate my own debs,
and thus haven't got the oportunity to test this patch. If anyone with the
skills helps me on setting that I could test them and fix possible issues.

If there's something I could change to make this patches better just let me know.

Regards
To+

[1] http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8519
[2] The default cronjob that is set using the debian/koha-common.cron.d file
is being disbaled by this patch to avoid collision.

Sponsored-by: Universidad Nacional de Córdoba
---
 debian/docs/koha-common.xml          |   21 ++++++++++++++
 debian/docs/koha-restart-indexer.xml |   43 +++++++++++++++++++++++++++++
 debian/docs/koha-start-indexer.xml   |   43 +++++++++++++++++++++++++++++
 debian/docs/koha-stop-indexer.xml    |   43 +++++++++++++++++++++++++++++
 debian/koha-common.cron.d            |    2 +-
 debian/koha-common.init              |    3 ++
 debian/koha-common.install           |    3 ++
 debian/scripts/koha-create           |    3 ++
 debian/scripts/koha-restart-indexer  |   50 ++++++++++++++++++++++++++++++++++
 debian/scripts/koha-start-indexer    |   50 ++++++++++++++++++++++++++++++++++
 debian/scripts/koha-stop-indexer     |   50 ++++++++++++++++++++++++++++++++++
 11 files changed, 310 insertions(+), 1 deletion(-)
 create mode 100644 debian/docs/koha-restart-indexer.xml
 create mode 100644 debian/docs/koha-start-indexer.xml
 create mode 100644 debian/docs/koha-stop-indexer.xml
 create mode 100755 debian/scripts/koha-restart-indexer
 create mode 100755 debian/scripts/koha-start-indexer
 create mode 100755 debian/scripts/koha-stop-indexer

diff --git a/debian/docs/koha-common.xml b/debian/docs/koha-common.xml
index 0e70595..2389043 100644
--- a/debian/docs/koha-common.xml
+++ b/debian/docs/koha-common.xml
@@ -131,6 +131,27 @@
           <para>Stop Zebra for named Koha instances.</para>
         </listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><option>koha-start-indexer</option></term>
+        <listitem>
+          <para>Start the indexer daemon for named Koha instances.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>koha-restart-indexer</option></term>
+        <listitem>
+          <para>Restart the indexer daemon for named Koha instances.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>koha-stop-indexer</option></term>
+        <listitem>
+          <para>Stop the indexer daemon for named Koha instances.</para>
+        </listitem>
+      </varlistentry>
     </variablelist>
     </refsect2>
 
diff --git a/debian/docs/koha-restart-indexer.xml b/debian/docs/koha-restart-indexer.xml
new file mode 100644
index 0000000..f9e20be
--- /dev/null
+++ b/debian/docs/koha-restart-indexer.xml
@@ -0,0 +1,43 @@
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-restart-indexer</title>
+<info>
+<productname>Koha</productname> is the first free software library automation package.
+<author>
+  <orgname>The Koha Communnity</orgname>
+  <uri>http://koha-community.org/</uri>
+</author>
+</info>
+
+<refentry xml:id="koha-restart-indexer">
+
+  <refmeta>
+    <refentrytitle>koha-restart-indexer</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>koha-restart-indexer</refname>
+    <refpurpose>Restart the indexer daemon for named Koha instances.</refpurpose>
+    <refclass>UNIX/Linux</refclass>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>koha-restart-indexer</command> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1><title>Description</title>
+  <para>Restart the indexer daemon for named Koha instances.</para>
+  </refsect1>
+  
+  <refsect1><title>See also</title>
+  <simplelist type="inline">
+    <member><command>koha-start-indexer(8)</command></member>
+    <member><command>koha-stop-indexer(8)</command></member>
+  </simplelist>
+  </refsect1>
+  
+</refentry>
+
+</article>
diff --git a/debian/docs/koha-start-indexer.xml b/debian/docs/koha-start-indexer.xml
new file mode 100644
index 0000000..cd59757
--- /dev/null
+++ b/debian/docs/koha-start-indexer.xml
@@ -0,0 +1,43 @@
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-start-indexer</title>
+<info>
+<productname>Koha</productname> is the first free software library automation package.
+<author>
+  <orgname>The Koha Communnity</orgname>
+  <uri>http://koha-community.org/</uri>
+</author>
+</info>
+
+<refentry xml:id="koha-start-indexer">
+
+  <refmeta>
+    <refentrytitle>koha-start-indexer</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>koha-start-indexer</refname>
+    <refpurpose>Start the indexer daemon for named Koha instances.</refpurpose>
+    <refclass>UNIX/Linux</refclass>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>koha-start-indexer</command> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1><title>Description</title>
+  <para>Start the indexer daemon for named Koha instances.</para>
+  </refsect1>
+  
+  <refsect1><title>See also</title>
+  <simplelist type="inline">
+    <member><command>koha-restart-indexer(8)</command></member>
+    <member><command>koha-stop-indexer(8)</command></member>
+  </simplelist>
+  </refsect1>
+  
+</refentry>
+
+</article>
diff --git a/debian/docs/koha-stop-indexer.xml b/debian/docs/koha-stop-indexer.xml
new file mode 100644
index 0000000..6652918
--- /dev/null
+++ b/debian/docs/koha-stop-indexer.xml
@@ -0,0 +1,43 @@
+<article xmlns='http://docbook.org/ns/docbook'>
+<title>koha-stop-indexer</title>
+<info>
+<productname>Koha</productname> is the first free software library automation package.
+<author>
+  <orgname>The Koha Communnity</orgname>
+  <uri>http://koha-community.org/</uri>
+</author>
+</info>
+
+<refentry xml:id="koha-stop-indexer">
+
+  <refmeta>
+    <refentrytitle>koha-stop-indexer</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>koha-stop-indexer</refname>
+    <refpurpose>Stop indexer daemon for named Koha instances.</refpurpose>
+    <refclass>UNIX/Linux</refclass>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>koha-stop-indexer</command> <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1><title>Description</title>
+  <para>Stop indexer daemon for named Koha instances.</para>
+  </refsect1>
+  
+  <refsect1><title>See also</title>
+  <simplelist type="inline">
+    <member><command>koha-restart-indexer(8)</command></member>
+    <member><command>koha-start-indexer(8)</command></member>
+  </simplelist>
+  </refsect1>
+  
+</refentry>
+
+</article>
diff --git a/debian/koha-common.cron.d b/debian/koha-common.cron.d
index cd7f3c2..c7fc94e 100644
--- a/debian/koha-common.cron.d
+++ b/debian/koha-common.cron.d
@@ -6,5 +6,5 @@
 SHELL=/bin/sh
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
-*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra $(koha-list --enabled)
+# */5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra $(koha-list --enabled)
 */15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl
diff --git a/debian/koha-common.init b/debian/koha-common.init
index 5be77d3..7946785 100755
--- a/debian/koha-common.init
+++ b/debian/koha-common.init
@@ -45,6 +45,7 @@ do_start()
     # We insure all required directories exist, including disabled ones.
     koha-create-dirs $(koha-list)
     koha-start-zebra $(koha-list --enabled)
+    koha-start-indexer $(koha-list --enabled)
 }
 
 #
@@ -54,6 +55,7 @@ do_stop()
 {
     # We stop everything, including disabled ones.
     koha-stop-zebra $(koha-list) || true
+    koha-stop-indexer $(koha-list --enabled)
 }
 
 #
@@ -61,6 +63,7 @@ do_stop()
 #
 do_reload() {
     koha-restart-zebra $(koha-list --enabled)
+    koha-restart-indexer $(koha-list --enabled)
 }
 
 case "$1" in
diff --git a/debian/koha-common.install b/debian/koha-common.install
index 50affbd..522bba3 100644
--- a/debian/koha-common.install
+++ b/debian/koha-common.install
@@ -21,10 +21,13 @@ debian/scripts/koha-mysql                   usr/sbin
 debian/scripts/koha-rebuild-zebra           usr/sbin
 debian/scripts/koha-remove                  usr/sbin
 debian/scripts/koha-reset-passwd            usr/sbin
+debian/scripts/koha-restart-indexer         usr/sbin
 debian/scripts/koha-restart-zebra           usr/sbin
 debian/scripts/koha-restore                 usr/sbin
 debian/scripts/koha-run-backups             usr/sbin
+debian/scripts/koha-start-indexer           usr/sbin
 debian/scripts/koha-start-zebra             usr/sbin
+debian/scripts/koha-stop-indexer            usr/sbin
 debian/scripts/koha-stop-zebra              usr/sbin
 debian/scripts/koha-upgrade-schema          usr/sbin
 debian/scripts/koha-upgrade-to-3.4          usr/sbin
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index b0c418c..5ec3349 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -340,6 +340,9 @@ then
 
     # Start Zebra.
     koha-start-zebra "$name"
+
+    # Start Indexer daemon
+    koha-start-indexer "$name"
 fi
 
 
diff --git a/debian/scripts/koha-restart-indexer b/debian/scripts/koha-restart-indexer
new file mode 100755
index 0000000..a45b9be
--- /dev/null
+++ b/debian/scripts/koha-restart-indexer
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# koha-restart-indexer -- Restart Indexer Daemon for named Koha instandes
+# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba
+# 
+# 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
+
+. /lib/lsb/init-functions
+
+INDEXDAEMON="koha-index-daemon"
+PERL5LIB="/usr/share/koha/lib"
+
+for name in "$@"
+do
+
+      KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
+
+      INDEXDAEMON_OPTS="--timeout 30 \
+                        --conf $KOHA_CONF \
+                        --directory /var/tmp/koha-indexer-daemon-$name"
+
+      DAEMONOPTS="--name=$name-koha-indexer \
+            --errlog=/var/log/koha/$name/koha-indexer-error.log \
+            --stdout=/var/log/koha/$name/koha-indexer.log \
+            --output=/var/log/koha/$name/koha-indexer-output.log \
+            --verbose=1 --respawn --delay=30 \
+            --user=$name-koha.$name-koha"
+
+      log_daemon_msg "Restarting Koha indexing daemon for $name"
+
+      if daemon $DAEMONOPTS --restart -- $INDEXDAEMON $INDEXDAEMON_OPTS; then
+        log_end_msg 0
+      else
+        log_end_msg 1
+      fi
+
+done
diff --git a/debian/scripts/koha-start-indexer b/debian/scripts/koha-start-indexer
new file mode 100755
index 0000000..8d77d88
--- /dev/null
+++ b/debian/scripts/koha-start-indexer
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# koha-start-indexer -- Start Indexer Daemon for named Koha instandes
+# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba
+# 
+# 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
+
+. /lib/lsb/init-functions
+
+INDEXDAEMON="koha-index-daemon"
+PERL5LIB="/usr/share/koha/lib"
+
+for name in "$@"
+do
+
+      KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
+
+      INDEXDAEMON_OPTS="--timeout 30 \
+                        --conf $KOHA_CONF \
+                        --directory /var/tmp/koha-indexer-daemon-$name"
+
+      DAEMONOPTS="--name=$name-koha-indexer \
+            --errlog=/var/log/koha/$name/koha-indexer-error.log \
+            --stdout=/var/log/koha/$name/koha-indexer.log \
+            --output=/var/log/koha/$name/koha-indexer-output.log \
+            --verbose=1 --respawn --delay=30 \
+            --user=$name-koha.$name-koha"
+
+      log_daemon_msg "Starting Koha indexing daemon for $name"
+
+      if daemon $DAEMONOPTS -- $INDEXDAEMON $INDEXDAEMON_OPTS; then
+        log_end_msg 0
+      else
+        log_end_msg 1
+      fi
+
+done
diff --git a/debian/scripts/koha-stop-indexer b/debian/scripts/koha-stop-indexer
new file mode 100755
index 0000000..f9a2153
--- /dev/null
+++ b/debian/scripts/koha-stop-indexer
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# koha-stop-indexer -- Stop Indexer Daemon for named Koha instandes
+# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba
+# 
+# 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
+
+. /lib/lsb/init-functions
+
+INDEXDAEMON="koha-index-daemon"
+PERL5LIB="/usr/share/koha/lib"
+
+for name in "$@"
+do
+
+      KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
+
+      INDEXDAEMON_OPTS="--timeout 30 \
+                        --conf $KOHA_CONF \
+                        --directory /var/tmp/koha-indexer-daemon-$name"
+
+      DAEMONOPTS="--name=$name-koha-indexer \
+            --errlog=/var/log/koha/$name/koha-indexer-error.log \
+            --stdout=/var/log/koha/$name/koha-indexer.log \
+            --output=/var/log/koha/$name/koha-indexer-output.log \
+            --verbose=1 --respawn --delay=30 \
+            --user=$name-koha.$name-koha"
+
+      log_daemon_msg "Stopping Koha indexing daemon for $name"
+
+      if daemon $DAEMONOPTS --stop -- $INDEXDAEMON $INDEXDAEMON_OPTS; then
+        log_end_msg 0
+      else
+        log_end_msg 1
+      fi
+
+done
-- 
1.7.9.5



More information about the Koha-patches mailing list