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

(-)a/debian/control.in (+1 lines)
Lines 23-28 Depends: ${misc:Depends}, ${koha:Depends}, Link Here
23
 daemon,
23
 daemon,
24
 debconf,
24
 debconf,
25
 idzebra-2.0,
25
 idzebra-2.0,
26
 inotify-tools,
26
 memcached,
27
 memcached,
27
 mysql-client | virtual-mysql-client,
28
 mysql-client | virtual-mysql-client,
28
 perl-doc,
29
 perl-doc,
(-)a/debian/koha-common.install (+1 lines)
Lines 33-38 debian/scripts/koha-sitemap usr/sbin Link Here
33
debian/scripts/koha-translate               usr/sbin
33
debian/scripts/koha-translate               usr/sbin
34
debian/scripts/koha-upgrade-schema          usr/sbin
34
debian/scripts/koha-upgrade-schema          usr/sbin
35
debian/scripts/koha-upgrade-to-3.4          usr/sbin
35
debian/scripts/koha-upgrade-to-3.4          usr/sbin
36
debian/scripts/koha-watcher                 usr/sbin
36
debian/scripts/koha-worker                  usr/sbin
37
debian/scripts/koha-worker                  usr/sbin
37
debian/scripts/koha-z3950-responder         usr/sbin
38
debian/scripts/koha-z3950-responder         usr/sbin
38
debian/scripts/koha-zebra                   usr/sbin
39
debian/scripts/koha-zebra                   usr/sbin
(-)a/debian/scripts/koha-plack (+34 lines)
Lines 62-67 $scriptname -h|--help Link Here
62
    --debugger-path       Specify the path for the debugger library
62
    --debugger-path       Specify the path for the debugger library
63
    --quiet|-q            Make the script quiet about non existent instance names
63
    --quiet|-q            Make the script quiet about non existent instance names
64
                          (useful for calling from another scripts).
64
                          (useful for calling from another scripts).
65
    --watch|-w            Enable automatic reload to starman/plack when a file
66
                           is modified (intended for development use)
65
    --help|-h             Display this help message
67
    --help|-h             Display this help message
66
68
67
EOF
69
EOF
Lines 131-136 start_plack() Link Here
131
        # Go back to the original dir
133
        # Go back to the original dir
132
        cd "$current_dir"
134
        cd "$current_dir"
133
135
136
        # start watcher
137
        if [ "${watch}" = "yes" ]; then
138
            start_watcher $instancename
139
        fi
140
134
    else
141
    else
135
        log_daemon_msg "Error: Plack already running for ${instancename}"
142
        log_daemon_msg "Error: Plack already running for ${instancename}"
136
        log_end_msg 1
143
        log_end_msg 1
Lines 152-163 stop_plack() Link Here
152
        else
159
        else
153
            log_end_msg 1
160
            log_end_msg 1
154
        fi
161
        fi
162
163
        # stop watcher
164
        if [ -f /var/run/koha/${instancename}/watcher.pid ]; then
165
            stop_watcher $instancename
166
        fi
167
155
    else
168
    else
156
        log_daemon_msg "Error: Plack not running for ${instancename}"
169
        log_daemon_msg "Error: Plack not running for ${instancename}"
157
        log_end_msg 1
170
        log_end_msg 1
158
    fi
171
    fi
159
}
172
}
160
173
174
161
restart_plack()
175
restart_plack()
162
{
176
{
163
    local instancename=$1
177
    local instancename=$1
Lines 294-299 disable_plack() Link Here
294
    fi
308
    fi
295
}
309
}
296
310
311
start_watcher()
312
{
313
    local instancename=$1
314
    PIDFILE="/var/run/koha/${instancename}/watcher.pid"
315
    start-stop-daemon --pidfile ${PIDFILE} --start --background \
316
        --make-pidfile --startas /usr/sbin/koha-watcher \
317
        -- -d $KOHA_HOME ${instancename}
318
}
319
320
stop_watcher()
321
{
322
    local instancename=$1
323
    PID=`cat /var/run/koha/${instancename}/watcher.pid`
324
    start-stop-daemon --ppid ${PID} --stop  --retry=QUIT/5/KILL/10
325
}
326
297
check_env_and_warn()
327
check_env_and_warn()
298
{
328
{
299
    local apache_version_ok="no"
329
    local apache_version_ok="no"
Lines 401-406 _do_instance() { Link Here
401
STARMAN=$(which starman)
431
STARMAN=$(which starman)
402
op=""
432
op=""
403
quiet="no"
433
quiet="no"
434
watch="no"
404
debug_mode="no"
435
debug_mode="no"
405
debugger_key=""
436
debugger_key=""
406
debugger_location="localhost:9000"
437
debugger_location="localhost:9000"
Lines 415-420 while [ $# -gt 0 ]; do Link Here
415
        -q|--quiet)
446
        -q|--quiet)
416
            quiet="yes"
447
            quiet="yes"
417
            shift ;;
448
            shift ;;
449
        -w|--watch)
450
            watch="yes"
451
            shift ;;
418
        --start)
452
        --start)
419
            set_action "start"
453
            set_action "start"
420
            shift ;;
454
            shift ;;
(-)a/debian/scripts/koha-watcher (-1 / +66 lines)
Line 0 Link Here
0
- 
1
#!/bin/sh
2
#
3
# koha-watcher -- Restart starman when a file is modified.
4
# Copyright 2022  Mason James
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
set -e
12
13
usage()
14
{
15
    local scriptname=$(basename $0)
16
17
    cat <<EOF
18
$scriptname
19
20
This script restarts starman when a file is modified, called from 'koha-plack --start --watch instance'
21
22
Not intended to be run manually
23
24
Usage:
25
$scriptname --dir $dirpath instancename
26
$scriptname -h|--help
27
28
    --dir|-d              Path of directory to be watched
29
    --help|-h             Display this help message
30
31
EOF
32
}
33
34
# Read command line parameters
35
while [ $# -gt 0 ]; do
36
    case "$1" in
37
        -h|--help)
38
            usage ; exit 0 ;;
39
        -d|--dir)
40
            dir="$2"
41
            shift 2 ;;
42
        *)
43
            # We expect the remaining stuff are the instance names
44
            instance=$1
45
            break ;;
46
    esac
47
done
48
49
if [ -z $dir ]; then
50
        echo "Error: you must provide a directory name"
51
        exit
52
elsif [ -z $instance ]; then
53
        echo "Error: you must provide at least one instance name"
54
        exit
55
fi
56
57
while inotifywait --recursive \
58
      --event MODIFY \
59
      --syslog \
60
      --outfile  /var/log/koha/$instance/plack-error.log \
61
      --excludei 'swp$' \
62
      $dir ; do
63
                kill -s HUP `cat /var/run/koha/$instance/plack.pid`
64
done
65
66
exit 0;

Return to bug 31729