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 |
- |
|
|