Bugzilla – Attachment 68617 Details for
Bug 19462
Add a koha-elasticsearch command
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19462: Add a koha-elasticsearch command
Bug-19462-Add-a-koha-elasticsearch-command.patch (text/plain), 6.54 KB, created by
Nick Clemens (kidclamp)
on 2017-10-26 14:48:10 UTC
(
hide
)
Description:
Bug 19462: Add a koha-elasticsearch command
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-10-26 14:48:10 UTC
Size:
6.54 KB
patch
obsolete
>From 7993712000ecb1e5ea21cbb881fbadf096e1ef81 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 13 Oct 2017 15:11:07 -0300 >Subject: [PATCH] Bug 19462: Add a koha-elasticsearch command > >This patch adds a new command to be used for Elasticsearch-related >tasks. > >The current implementation only offers the --rebuild action switch, >that allows reindexing Elasticsearch on a per-instance basis as we are >used to with the rest of the koha-* commands. > >Other options could be added in a future: --status (ES server status >report, etc). > >To test: >- Apply the whole patchset >- Have a suitable Koha+Elasticsearch setup [1] >- Run: > $ reset_all >- Run: > $ man koha-elasticsearch >=> SUCCESS: A pretty man page is displayed covering all options >- Run: > $ sudo koha-elasticsearch blah >=> SUCCESS: The script fails because blah is not a valid instance name >- Run: > $ sudo koha-elasticsearch -v kohadev >=> SUCCESS: Reindex happens! >- Try the -a, -b and -c option switches >- Sign off happily :-D > >Sponsored-by: ByWater Solutions > >[1] This is straightforward if you are using KohaDevBox and created the >box using: $ KOHA_ELASTICSEARCH=1 vagrant up > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > debian/koha-common.install | 1 + > debian/scripts/koha-elasticsearch | 180 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 181 insertions(+) > create mode 100755 debian/scripts/koha-elasticsearch > >diff --git a/debian/koha-common.install b/debian/koha-common.install >index 270a54a..be3fbd9 100644 >--- a/debian/koha-common.install >+++ b/debian/koha-common.install >@@ -13,6 +13,7 @@ debian/scripts/koha-create-dirs usr/sbin > debian/scripts/koha-disable usr/sbin > debian/scripts/koha-dump usr/sbin > debian/scripts/koha-dump-defaults usr/sbin >+debian/scripts/koha-elasticsearch usr/sbin > debian/scripts/koha-email-disable usr/sbin > debian/scripts/koha-email-enable usr/sbin > debian/scripts/koha-enable usr/sbin >diff --git a/debian/scripts/koha-elasticsearch b/debian/scripts/koha-elasticsearch >new file mode 100755 >index 0000000..243c345 >--- /dev/null >+++ b/debian/scripts/koha-elasticsearch >@@ -0,0 +1,180 @@ >+#!/bin/sh >+ >+# 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 >+ >+# Read configuration variable file if it is present >+[ -r /etc/default/koha-common ] && . /etc/default/koha-common >+ >+# 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 >+ >+usage() >+{ >+ local scriptname=$0 >+ cat <<EOF >+Manage Elasticsearch-related tasks for Koha instances >+ >+Usage: $scriptname [actions] [options] instancename1 instancename2... >+ >+Actions: >+ --rebuild Trigger a rebuild process >+ >+Options: >+ --authorities|-a Only run process for authorities. >+ --biblios|-b Only run process for biblios. >+ -c|--commit n Specify how many records will be batched up before >+ they're added to Elasticsearch (default: 5000). >+ --verbose|-v Be verbose. >+ --help|-h Print this help. >+ >+EOF >+} >+ >+toggle_biblios_only() >+{ >+ biblios_only="yes" >+ biblios="yes" >+ if [ "${authorities_only}" != "yes" ]; then >+ authorities="no" >+ fi >+} >+ >+toggle_authorities_only() >+{ >+ authorities_only="yes" >+ authorities="yes" >+ if [ "${biblios_only}" != "yes" ]; then >+ biblios="no" >+ fi >+} >+ >+set_action() >+{ >+ if [ "${op}" = "" ]; then >+ op=$1 >+ else >+ die "Error: only one action can be specified." >+ fi >+} >+ >+run_rebuild_elasticsearch() >+{ >+ # read instance name and eliminate instance name from params >+ local name=$1; shift >+ >+ if [ "$DEV_INSTALL" = "" ]; then >+ KOHA_BINDIR=${KOHA_HOME}/bin >+ else >+ KOHA_BINDIR=${KOHA_HOME}/misc >+ fi >+ >+ if [ "${clo_commit_size}" > 0 ]; then >+ commit_size=${clo_commit_size} >+ fi >+ rebuild_opts="--commit ${commit_size}" >+ >+ if [ "${biblios}" = "yes" ]; then >+ rebuild_opts="${rebuild_opts} -b" >+ fi >+ >+ if [ "${authorities}" = "yes" ]; then >+ rebuild_opts="${rebuild_opts} -a" >+ fi >+ >+ if [ "${verbose}" = "yes" ]; then >+ rebuild_opts="${rebuild_opts} -v" >+ fi >+ >+ if koha-shell \ >+ -c "${KOHA_BINDIR}/search_tools/rebuild_elastic_search.pl ${rebuild_opts}" \ >+ ${name}; then >+ return 0 >+ else >+ return 1 >+ fi >+} >+ >+# Default parameters >+biblios="yes" >+authorities="yes" >+biblios_only="no" >+authorities_only="no" >+commit_size=5000 >+verbose="no" >+op="" >+ >+# Read parameters >+while [ -n "$*" ]; do >+ case "$1" in >+ -h|--help) >+ usage ; exit 0 >+ ;; >+ -b|--biblios) >+ toggle_biblios_only >+ ;; >+ -a|--authorities) >+ toggle_authorities_only >+ ;; >+ -c|--commit) >+ clo_commit_size="$2" ; shift >+ ;; >+ --rebuild) >+ set_action "rebuild" >+ ;; >+ -v|--verbose) >+ verbose="yes" >+ ;; >+ *) >+ break >+ ;; >+ esac >+ >+ shift >+done >+ >+# Optionally use alternative paths for a dev install >+adjust_paths_dev_install $1 >+ >+# Parse command line. >+if [ $# -lt 1 ]; then >+ usage >+ die "Missing instance name." >+fi >+ >+# Loop over instance names >+for name in "$@" >+do >+ if is_instance $name; then >+ if [ "${op}" = "rebuild" ]; then >+ if ! run_rebuild_elasticsearch $name; then >+ warn "Something went wrong rebuilding indexes for ${name}" >+ fi >+ else >+ # TODO: Add other actions, status? etc >+ usage >+ die "Error: no action passed" >+ fi >+ else >+ warn "Unknown instance ${name}" >+ fi >+done >+ >+exit 0 >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19462
:
68091
|
68092
|
68118
|
68119
| 68617 |
68618