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

(-)a/debian/scripts/koha-plack (-7 / +9 lines)
Lines 152-157 stop_plack() Link Here
152
152
153
    if is_plack_running ${instancename}; then
153
    if is_plack_running ${instancename}; then
154
154
155
        # stop watcher
156
        if [ -f /var/run/koha/${instancename}/watcher.pid ]; then
157
            stop_watcher $instancename
158
        fi
159
155
        log_daemon_msg "Stopping Plack daemon for ${instancename}"
160
        log_daemon_msg "Stopping Plack daemon for ${instancename}"
156
161
157
        if start-stop-daemon --pidfile ${PIDFILE} --user="${instancename}-koha" --stop --retry=QUIT/30/KILL/5; then
162
        if start-stop-daemon --pidfile ${PIDFILE} --user="${instancename}-koha" --stop --retry=QUIT/30/KILL/5; then
Lines 160-170 stop_plack() Link Here
160
            log_end_msg 1
165
            log_end_msg 1
161
        fi
166
        fi
162
167
163
        # stop watcher
164
        if [ -f /var/run/koha/${instancename}/watcher.pid ]; then
165
            stop_watcher $instancename
166
        fi
167
168
    else
168
    else
169
        log_daemon_msg "Error: Plack not running for ${instancename}"
169
        log_daemon_msg "Error: Plack not running for ${instancename}"
170
        log_end_msg 1
170
        log_end_msg 1
Lines 320-327 start_watcher() Link Here
320
stop_watcher()
320
stop_watcher()
321
{
321
{
322
    local instancename=$1
322
    local instancename=$1
323
    PID=`cat /var/run/koha/${instancename}/watcher.pid`
323
    if $PID ; then
324
    start-stop-daemon --ppid ${PID} --stop  --retry=QUIT/5/KILL/10
324
        PID=`cat /var/run/koha/${instancename}/watcher.pid`
325
        start-stop-daemon --ppid ${PID} --stop
326
    fi
325
}
327
}
326
328
327
check_env_and_warn()
329
check_env_and_warn()
(-)a/debian/scripts/koha-watcher (-5 / +27 lines)
Lines 26-36 $scriptname --dir $dirpath instancename Link Here
26
$scriptname -h|--help
26
$scriptname -h|--help
27
27
28
    --dir|-d              Path of directory to be watched
28
    --dir|-d              Path of directory to be watched
29
    --sec|-s              Seconds between reloads (default is 2)
29
    --help|-h             Display this help message
30
    --help|-h             Display this help message
30
31
31
EOF
32
EOF
32
}
33
}
33
34
35
sec=2
34
# Read command line parameters
36
# Read command line parameters
35
while [ $# -gt 0 ]; do
37
while [ $# -gt 0 ]; do
36
    case "$1" in
38
    case "$1" in
Lines 39-44 while [ $# -gt 0 ]; do Link Here
39
        -d|--dir)
41
        -d|--dir)
40
            dir="$2"
42
            dir="$2"
41
            shift 2 ;;
43
            shift 2 ;;
44
        -s|--sec)
45
            sec="$2"
46
            shift 2 ;;
42
        *)
47
        *)
43
            # We expect the remaining stuff are the instance names
48
            # We expect the remaining stuff are the instance names
44
            instance=$1
49
            instance=$1
Lines 49-65 done Link Here
49
if [ -z $dir ]; then
54
if [ -z $dir ]; then
50
        echo "Error: you must provide a directory name"
55
        echo "Error: you must provide a directory name"
51
        exit
56
        exit
52
elsif [ -z $instance ]; then
57
elif [ -z $instance ]; then
53
        echo "Error: you must provide an instance name"
58
        echo "Error: you must provide an instance name"
54
        exit
59
        exit
55
fi
60
fi
56
61
62
logfile1="/var/log/koha/$instance/koha-watcher.log"
63
logfile2="/var/log/koha/$instance/plack-error.log"
64
65
# watch perl files in a dir
66
watch_dir() {
57
inotifywait  --recursive -m  --event CLOSE_WRITE $dir | \
67
inotifywait  --recursive -m  --event CLOSE_WRITE $dir | \
58
    egrep '\.pl$|\.pm$' --line-buffered | \
68
    egrep '\.pl$|\.pm$' --line-buffered | \
59
    while read path events file;
69
    while read path events file; do
60
        do
70
            echo "$events happened to $file in $path" | tee -a  $logfile1 $logfile2
61
            echo "$events happened to $file in $path" >> /var/log/koha/$instance/plack-error.log 
71
    done;
72
}
73
74
start_reload_loop() {
75
    while true; do
76
        # restart, if logfile exists
77
        if [ -e $logfile1 ]; then
62
            kill -s HUP `cat /var/run/koha/$instance/plack.pid`
78
            kill -s HUP `cat /var/run/koha/$instance/plack.pid`
79
            rm $logfile1
80
        fi
81
        sleep $sec
63
    done;
82
    done;
83
}
84
85
start_reload_loop &
86
watch_dir
64
87
65
exit 0
88
exit 0
66
- 

Return to bug 31729