View | Details | Raw Unified | Return to bug 8773
Collapse All | Expand All

(-)a/debian/docs/koha-common.xml (+7 lines)
Lines 145-150 Link Here
145
          <para>Stop Zebra for named Koha instances.</para>
145
          <para>Stop Zebra for named Koha instances.</para>
146
        </listitem>
146
        </listitem>
147
      </varlistentry>
147
      </varlistentry>
148
149
      <varlistentry>
150
        <term><option>koha-indexer</option></term>
151
        <listitem>
152
          <para>Manage the indexer daemon for named Koha instances.</para>
153
        </listitem>
154
      </varlistentry>
148
    </variablelist>
155
    </variablelist>
149
    </refsect2>
156
    </refsect2>
150
157
(-)a/debian/docs/koha-indexer.xml (+72 lines)
Line 0 Link Here
1
<article xmlns='http://docbook.org/ns/docbook'>
2
<title>koha-indexer</title>
3
<info>
4
<productname>Koha</productname> is the first free software library automation package.
5
<author>
6
  <orgname>The Koha Community</orgname>
7
  <uri>http://koha-community.org/</uri>
8
</author>
9
</info>
10
11
<refentry xml:id="koha-indexer">
12
13
  <refmeta>
14
    <refentrytitle>koha-indexer</refentrytitle>
15
    <manvolnum>8</manvolnum>
16
  </refmeta>
17
18
  <refnamediv>
19
    <refname>koha-indexer</refname>
20
    <refpurpose>Manage the indexer daemon for Koha instances.</refpurpose>
21
    <refclass>UNIX/Linux</refclass>
22
  </refnamediv>
23
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
26
      <command>koha-indexer</command>
27
      <arg choice="req"><option>--start</option>|<option>--stop</option>|<option>--restart</option>|<option>--help</option>|<option>-h</option></arg>
28
      <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg>
29
    </cmdsynopsis>
30
  </refsynopsisdiv>
31
32
  <refsect1><title>Options</title>
33
34
  <variablelist>
35
36
    <varlistentry>
37
      <term><option>--start</option></term>
38
      <listitem>
39
        <para>Start the indexer daemon for the desired Koha instances.</para>
40
      </listitem>
41
    </varlistentry>
42
43
    <varlistentry>
44
      <term><option>--stop</option></term>
45
      <listitem>
46
        <para>Stop the indexer daemon for the desired Koha instances.</para>
47
      </listitem>
48
    </varlistentry>
49
50
    <varlistentry>
51
      <term><option>--restart</option></term>
52
      <listitem>
53
        <para>Restart the indexer daemon for the desired Koha instances.</para>
54
      </listitem>
55
    </varlistentry>
56
57
  </variablelist>
58
  </refsect1>
59
60
  <refsect1><title>Description</title>
61
    <para>The <command>koha-indexer</command> script lets you manage your Koha instances indexer daemon.</para>
62
  </refsect1>
63
64
  <refsect1><title>See also</title>
65
  <simplelist type="inline">
66
    <member><command>/etc/default/koha-common</command></member>
67
  </simplelist>
68
  </refsect1>
69
70
</refentry>
71
72
</article>
(-)a/debian/koha-common.cron.d (+1 lines)
Lines 6-10 Link Here
6
SHELL=/bin/sh
6
SHELL=/bin/sh
7
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
7
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
8
8
9
# Comment the following line if you want to use the experimental koha-index-daemon integration
9
*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled)
10
*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled)
10
*/15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl
11
*/15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl
(-)a/debian/koha-common.default (+21 lines)
Line 0 Link Here
1
## General koha-common default options file
2
3
PERL5LIB="/usr/share/koha/lib"
4
5
# If you want to use the koha-index-daemon script that is part of the
6
# Koha::Contrib::Tamil package instead of the cronjob, set USE_INDEXER_DAEMON
7
# to "yes". More information can be found here:
8
#     http://wiki.koha-community.org/wiki/PackagesIndexDaemon
9
# Note: You should comment the relevant line in /etc/cron.d/koha-common
10
#
11
# The default value is "no"
12
USE_INDEXER_DAEMON="no"
13
14
# Indexer daemon script. The default is to use Tamil's
15
INDEXER_DAEMON="koha-index-daemon"
16
17
# If you are using the koha-index-daemon you can set the frecquency (in sec)
18
# of the indexes update.
19
#
20
# The default value is 30
21
INDEXER_TIMEOUT=30
(-)a/debian/koha-common.init (-19 / +15 lines)
Lines 18-34 Link Here
18
# PATH should only include /usr/* if it runs after the mountnfs.sh script
18
# PATH should only include /usr/* if it runs after the mountnfs.sh script
19
PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
PATH=/sbin:/usr/sbin:/bin:/usr/bin
20
DESC="Koha ILS"
20
DESC="Koha ILS"
21
NAME=daemonexecutablename
21
NAME="koha-common"
22
DAEMON=/usr/sbin/$NAME
23
DAEMON_ARGS="--options args"
24
PIDFILE=/var/run/$NAME.pid
25
SCRIPTNAME=/etc/init.d/$NAME
22
SCRIPTNAME=/etc/init.d/$NAME
26
23
27
# Exit if the package is not installed
24
# Exit if the package is not installed
28
[ -x /usr/sbin/koha-start-zebra ] || exit 0
25
[ -x /usr/sbin/koha-start-zebra ] || exit 0
29
26
30
# Read configuration variable file if it is present
27
# Read configuration variable file if it is present
31
# [ -r /etc/default/$NAME ] && . /etc/default/$NAME
28
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
32
29
33
# Load the VERBOSE setting and other rcS variables
30
# Load the VERBOSE setting and other rcS variables
34
. /lib/init/vars.sh
31
. /lib/init/vars.sh
Lines 46-51 do_start() Link Here
46
    koha-create-dirs $(koha-list)
43
    koha-create-dirs $(koha-list)
47
    koha-start-zebra $(koha-list --enabled)
44
    koha-start-zebra $(koha-list --enabled)
48
    koha-start-sip $(koha-list --enabled)
45
    koha-start-sip $(koha-list --enabled)
46
47
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
48
        koha-indexer --start $(koha-list --enabled)
49
    fi
49
}
50
}
50
51
51
#
52
#
Lines 56-61 do_stop() Link Here
56
    # We stop everything, including disabled ones.
57
    # We stop everything, including disabled ones.
57
    koha-stop-zebra $(koha-list) || true
58
    koha-stop-zebra $(koha-list) || true
58
    koha-stop-sip $(koha-list) || true
59
    koha-stop-sip $(koha-list) || true
60
61
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
62
        koha-indexer --stop $(koha-list --enabled)
63
    fi
59
}
64
}
60
65
61
#
66
#
Lines 65-70 do_reload() { Link Here
65
    koha-restart-zebra $(koha-list --enabled)
70
    koha-restart-zebra $(koha-list --enabled)
66
    koha-stop-sip $(koha-list) || true
71
    koha-stop-sip $(koha-list) || true
67
    koha-start-sip $(koha-list --enabled)
72
    koha-start-sip $(koha-list --enabled)
73
74
    if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
75
        koha-indexer --restart $(koha-list --enabled)
76
    fi
68
}
77
}
69
78
70
case "$1" in
79
case "$1" in
Lines 84-101 case "$1" in Link Here
84
		*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
93
		*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
85
	esac
94
	esac
86
	;;
95
	;;
87
#  status)
88
#       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
89
#       ;;
90
  #reload|force-reload)
91
	#
92
	# If do_reload() is not implemented then leave this commented out
93
	# and leave 'force-reload' as an alias for 'restart'.
94
	#
95
	#log_daemon_msg "Reloading $DESC" "$NAME"
96
	#do_reload
97
	#log_end_msg $?
98
	#;;
99
  restart|force-reload)
96
  restart|force-reload)
100
	#
97
	#
101
	# If the "reload" option is implemented then remove the
98
	# If the "reload" option is implemented then remove the
Lines 118-125 case "$1" in Link Here
118
	esac
115
	esac
119
	;;
116
	;;
120
  *)
117
  *)
121
	echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
118
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
122
	#echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
123
	exit 3
119
	exit 3
124
	;;
120
	;;
125
esac
121
esac
(-)a/debian/koha-common.install (+1 lines)
Lines 17-22 debian/scripts/koha-email-disable usr/sbin Link Here
17
debian/scripts/koha-email-enable            usr/sbin
17
debian/scripts/koha-email-enable            usr/sbin
18
debian/scripts/koha-enable                  usr/sbin
18
debian/scripts/koha-enable                  usr/sbin
19
debian/scripts/koha-foreach                 usr/sbin
19
debian/scripts/koha-foreach                 usr/sbin
20
debian/scripts/koha-indexer                 usr/sbin
20
debian/scripts/koha-list                    usr/sbin
21
debian/scripts/koha-list                    usr/sbin
21
debian/scripts/koha-mysql                   usr/sbin
22
debian/scripts/koha-mysql                   usr/sbin
22
debian/scripts/koha-rebuild-zebra           usr/sbin
23
debian/scripts/koha-rebuild-zebra           usr/sbin
(-)a/debian/scripts/koha-create (+3 lines)
Lines 341-346 then Link Here
341
341
342
    # Start Zebra.
342
    # Start Zebra.
343
    koha-start-zebra "$name"
343
    koha-start-zebra "$name"
344
345
    # Start Indexer daemon
346
    koha-start-indexer "$name"
344
fi
347
fi
345
348
346
349
(-)a/debian/scripts/koha-indexer (-1 / +266 lines)
Line 0 Link Here
0
- 
1
#!/bin/bash
2
#
3
# koha-indexer - Manage Indexer Daemons for Koha instances
4
# Copyright 2012 Tomás Cohen Arazi @ Universidad Nacional de Córdoba
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
set -e
20
21
. /lib/lsb/init-functions
22
23
# Read configuration variable file if it is present
24
[ -r /etc/default/koha-common ] && . /etc/default/koha-common
25
26
warn()
27
{
28
    echo "$@" 1>&2
29
}
30
31
die()
32
{
33
    echo "$@" 1>&2
34
    exit 1
35
}
36
37
usage()
38
{
39
    local scriptname=$(basename $0)
40
41
    cat <<EOF
42
$scriptname
43
44
This script lets you manage the indexer daemon for your Koha instances.
45
46
Usage:
47
$scriptname [--start|--stop|--restart] instancename1 [instancename2...]
48
$scriptname -h|--help
49
50
    --start               Start the indexer daemon for the specified instances
51
    --stop                Stop the indexer daemon for the specified instances
52
    --restart             Restart the indexer daemon for the specified instances
53
    --help|-h             Display this help message
54
55
EOF
56
}
57
58
is_instance()
59
{
60
    local instancename=$1
61
62
    if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
63
                         -type d -printf '%f\n'\
64
          | grep -q -x -e "$instancename" ; then
65
        return 0
66
    else
67
        return 1
68
    fi
69
}
70
71
is_indexer_running()
72
{
73
    local instancename=$1
74
75
    if daemon --name="$instancename-koha-indexer" \
76
            --user="$instancename-koha.$instancename-koha" \
77
            --running ; then
78
        return 0
79
    else
80
        return 1
81
    fi
82
}
83
84
start_indexer()
85
{
86
    local name=$1
87
88
    if ! is_indexer_running $name; then
89
        export KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
90
91
        INDEXDAEMON_OPTS="--timeout $INDEXER_TIMEOUT \
92
                        --conf $KOHA_CONF \
93
                        --directory /var/tmp/koha-indexer-daemon-$name"
94
95
        DAEMONOPTS="--name=$name-koha-indexer \
96
            --errlog=/var/log/koha/$name/indexer-error.log \
97
            --stdout=/var/log/koha/$name/indexer.log \
98
            --output=/var/log/koha/$name/indexer-output.log \
99
            --verbose=1 --respawn --delay=30 \
100
            --user=$name-koha.$name-koha"
101
102
        log_daemon_msg "Starting Koha indexing daemon for $name"
103
104
        if daemon $DAEMONOPTS -- $INDEXER_DAEMON $INDEXDAEMON_OPTS; then
105
            log_end_msg 0
106
        else
107
            log_end_msg 1
108
        fi
109
    else
110
        log_daemon_msg "Error: Indexer already running for $name"
111
        log_end_msg 1
112
    fi
113
}
114
115
stop_indexer()
116
{
117
    local name=$1
118
119
    if is_indexer_running $name; then
120
        export KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
121
122
        INDEXDAEMON_OPTS="--timeout 30 \
123
                        --conf $KOHA_CONF \
124
                        --directory /var/tmp/koha-indexer-daemon-$name"
125
126
        DAEMONOPTS="--name=$name-koha-indexer \
127
            --errlog=/var/log/koha/$name/indexer-error.log \
128
            --stdout=/var/log/koha/$name/indexer.log \
129
            --output=/var/log/koha/$name/indexer-output.log \
130
            --verbose=1 --respawn --delay=30 \
131
            --user=$name-koha.$name-koha"
132
133
        log_daemon_msg "Stopping Koha indexing daemon for $name"
134
135
        if daemon $DAEMONOPTS --stop -- $INDEXER_DAEMON $INDEXDAEMON_OPTS; then
136
            log_end_msg 0
137
        else
138
            log_end_msg 1
139
        fi
140
    else
141
        log_daemon_msg "Error: Indexer not running for $name"
142
        log_end_msg 1
143
    fi
144
}
145
146
restart_indexer()
147
{
148
    local name=$1
149
150
    if is_indexer_running $name; then
151
        export KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml"
152
153
        INDEXDAEMON_OPTS="--timeout 30 \
154
                        --conf $KOHA_CONF \
155
                        --directory /var/tmp/koha-indexer-daemon-$name"
156
157
        DAEMONOPTS="--name=$name-koha-indexer \
158
            --errlog=/var/log/koha/$name/indexer-error.log \
159
            --stdout=/var/log/koha/$name/indexer.log \
160
            --output=/var/log/koha/$name/indexer-output.log \
161
            --verbose=1 --respawn --delay=30 \
162
            --user=$name-koha.$name-koha"
163
164
        log_daemon_msg "Stopping Koha indexing daemon for $name"
165
166
        if daemon $DAEMONOPTS --restart -- $INDEXER_DAEMON $INDEXDAEMON_OPTS; then
167
            log_end_msg 0
168
        else
169
            log_end_msg 1
170
        fi
171
    else
172
        log_daemon_msg "Error: Indexer not running for $name"
173
        log_end_msg 1
174
    fi
175
}
176
177
set_action()
178
{
179
    if [ "$op" = "" ]; then
180
        op=$1
181
    else
182
        die "Error: only one action can be specified."
183
    fi
184
}
185
186
# Read command line parameters
187
while [ $# -gt 0 ]; do
188
189
    case "$1" in
190
        -h|--help)
191
            op="help" ; break ;;
192
        --start)
193
            set_action "start"
194
            shift ;;
195
        --stop)
196
            set_action "stop"
197
            shift ;;
198
        --restart)
199
            set_action "restart"
200
            shift ;;
201
        -*)
202
            die "Error: invalid option switch ($1)" ;;
203
        *)
204
            # We expect the remaining stuff are the instance names
205
            break ;;
206
    esac
207
208
done
209
210
# Some default variables
211
if [ -z $INDEXER_DAEMON ]; then
212
    INDEXER_DAEMON="koha-index-daemon"
213
fi
214
215
if [ -z $PERL5LIB ]; then
216
    PERL5LIB="/usr/share/koha/lib"
217
fi
218
219
export PERL5LIB
220
221
if [ $INDEXER_TIMEOUT -lt 1 ]; then
222
    # Something's wrong, default to 30
223
    INDEXER_TIMEOUT=30
224
fi
225
226
227
if [ ! -e /usr/share/perl5/Koha/Contrib/Tamil/IndexerDaemon.pm ] ; then
228
    MSG=`cat <<EOF
229
Koha::Contrib::Tamil::IndexerDaemon was not found. See
230
http://wiki.koha-community.org/wiki/PackagesIndexDaemon
231
for instructions on setting up the indexer daemon.
232
EOF`
233
234
    die $MSG
235
fi
236
237
238
if [ $# -gt 0 ]; then
239
    # We have at least one instance name
240
    for name in "$@"; do
241
242
        if is_instance $name; then
243
244
            case $op in
245
                "start")
246
                    start_indexer $name
247
                    ;;
248
                "stop")
249
                    stop_indexer $name
250
                    ;;
251
                "restart")
252
                    restart_indexer $name
253
                    ;;
254
            esac
255
256
        else
257
            log_daemon_msg "Error: Invalid instance name $name"
258
            log_end_msg 1
259
        fi
260
261
    done
262
else
263
    die "Error: you must provide at least one instance name"
264
fi
265
266
exit 0

Return to bug 8773