filewatch 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/globtail +55 -0
- data/lib/filewatch/buftok.rb +2 -2
- data/lib/filewatch/tail.rb +171 -48
- data/lib/filewatch/watch.rb +145 -26
- data/test/globtail/Makefile +7 -0
- data/test/globtail/framework.sh +58 -0
- data/test/globtail/test1.data +5 -0
- data/test/globtail/test1.sh +17 -0
- data/test/globtail/test10.data +4 -0
- data/test/globtail/test10.sh +20 -0
- data/test/globtail/test2.data +2 -0
- data/test/globtail/test2.sh +17 -0
- data/test/globtail/test3.data +3 -0
- data/test/globtail/test3.sh +18 -0
- data/test/globtail/test4.data +4 -0
- data/test/globtail/test4.sh +16 -0
- data/test/globtail/test5.data +6 -0
- data/test/globtail/test5.sh +25 -0
- data/test/globtail/test6.data +6 -0
- data/test/globtail/test6.sh +29 -0
- data/test/globtail/test7.data +5 -0
- data/test/globtail/test7.sh +24 -0
- data/test/globtail/test8.data +5 -0
- data/test/globtail/test8.sh +23 -0
- data/test/globtail/test9.data +3 -0
- data/test/globtail/test9.sh +22 -0
- metadata +38 -38
- data/bin/gtail +0 -50
- data/lib/filewatch/exception.rb +0 -12
- data/lib/filewatch/inotify/emhandler.rb +0 -16
- data/lib/filewatch/inotify/event.rb +0 -101
- data/lib/filewatch/inotify/fd.rb +0 -319
- data/lib/filewatch/namespace.rb +0 -3
- data/lib/filewatch/rubyfixes.rb +0 -8
- data/lib/filewatch/stringpipeio.rb +0 -33
- data/lib/filewatch/tailglob.rb +0 -244
- data/lib/filewatch/watchglob.rb +0 -83
- data/test/log4j/LogTest.java +0 -21
- data/test/log4j/log4j.properties +0 -20
- data/test/logrotate/logrotate.conf +0 -5
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
test_init() {
|
4
|
+
export TEST_BASE=$(dirname $0)
|
5
|
+
export FW_BASE="$TEST_BASE/../.."
|
6
|
+
export RUBYLIB=$FW_BASE/lib:$RUBYLIB
|
7
|
+
export SINCEDB=$(mktemp)
|
8
|
+
export TAIL="$FW_BASE/bin/globtail -v -s $SINCEDB -i 5 -x skip*.log"
|
9
|
+
export TEST_DIR=$(mktemp -d)
|
10
|
+
export TEST_OUT=$(mktemp)
|
11
|
+
touch $TEST_OUT
|
12
|
+
mkdir -p $TEST_DIR
|
13
|
+
}
|
14
|
+
|
15
|
+
test_start() {
|
16
|
+
$TAIL "$TEST_DIR/*" >>$TEST_OUT 2>&1 &
|
17
|
+
export TEST_TAIL_PID=$!
|
18
|
+
|
19
|
+
# let globtail get started and do it's initial glob
|
20
|
+
sleep 3
|
21
|
+
}
|
22
|
+
|
23
|
+
test_stop() {
|
24
|
+
kill $TEST_TAIL_PID 2>/dev/null
|
25
|
+
count=0
|
26
|
+
while kill -0 $TEST_TAIL_PID 2>/dev/null; do
|
27
|
+
count=$((count+1))
|
28
|
+
sleep 1
|
29
|
+
if [ "$count" -eq 5 ]; then
|
30
|
+
kill -9 $TEST_TAIL_PID
|
31
|
+
count=0
|
32
|
+
fi
|
33
|
+
done
|
34
|
+
export TEST_TAIL_PID=""
|
35
|
+
}
|
36
|
+
|
37
|
+
test_done() {
|
38
|
+
[ -n "$TEST_TAIL_PID" ] && test_stop
|
39
|
+
|
40
|
+
output=$(mktemp)
|
41
|
+
output_clean=$(mktemp)
|
42
|
+
sed -e "s,^${TEST_DIR}/,," $TEST_OUT | sort > $output
|
43
|
+
sed -e '/^D, \[/d' < $output > $output_clean
|
44
|
+
|
45
|
+
data_file=$(echo $0 | sed -e 's/\.sh$/.data/')
|
46
|
+
|
47
|
+
diff $TEST_BASE/$data_file $output_clean >/dev/null
|
48
|
+
diff_rc=$?
|
49
|
+
|
50
|
+
if [ $diff_rc -ne 0 ]; then
|
51
|
+
diff -u $TEST_BASE/$data_file $output_clean
|
52
|
+
echo "$0 TEST FAILURE (output differs)"
|
53
|
+
sed -e 's,^,output: ,' $TEST_OUT
|
54
|
+
fi
|
55
|
+
|
56
|
+
rm -rf $TEST_DIR $TEST_OUT $output $output_clean $SINCEDB
|
57
|
+
exit $diff_rc
|
58
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: basic tail support
|
3
|
+
|
4
|
+
. $(dirname $0)/framework.sh
|
5
|
+
|
6
|
+
test_init
|
7
|
+
test_start
|
8
|
+
|
9
|
+
echo a > $TEST_DIR/a.log
|
10
|
+
echo b > $TEST_DIR/b.log
|
11
|
+
echo c > $TEST_DIR/c.log
|
12
|
+
echo a >> $TEST_DIR/a.log
|
13
|
+
echo c >> $TEST_DIR/c.log
|
14
|
+
|
15
|
+
sleep 5
|
16
|
+
|
17
|
+
test_done
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: file rename & old file name having new data
|
3
|
+
|
4
|
+
. $(dirname $0)/framework.sh
|
5
|
+
|
6
|
+
test_init
|
7
|
+
test_start
|
8
|
+
|
9
|
+
echo 1 > $TEST_DIR/a.log
|
10
|
+
sleep 8
|
11
|
+
|
12
|
+
echo 2 >> $TEST_DIR/a.log
|
13
|
+
sleep 3
|
14
|
+
|
15
|
+
echo 3 >> $TEST_DIR/a.log
|
16
|
+
mv $TEST_DIR/a.log $TEST_DIR/b.log
|
17
|
+
echo 4 > $TEST_DIR/a.log
|
18
|
+
sleep 8
|
19
|
+
|
20
|
+
test_done
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: tests glob discovery of a new file, and in-memory sincedb
|
3
|
+
# preserving file position after a rename
|
4
|
+
|
5
|
+
. $(dirname $0)/framework.sh
|
6
|
+
|
7
|
+
test_init
|
8
|
+
test_start
|
9
|
+
|
10
|
+
echo a > $TEST_DIR/a.log
|
11
|
+
sleep 5
|
12
|
+
mv $TEST_DIR/a.log $TEST_DIR/b.log
|
13
|
+
sleep 5
|
14
|
+
echo b >> $TEST_DIR/b.log
|
15
|
+
sleep 3
|
16
|
+
|
17
|
+
test_done
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: tests glob discovery of a new file, and in-memory sincedb
|
3
|
+
# preserving file position after a rename
|
4
|
+
|
5
|
+
. $(dirname $0)/framework.sh
|
6
|
+
|
7
|
+
test_init
|
8
|
+
test_start
|
9
|
+
|
10
|
+
echo a > $TEST_DIR/a.log
|
11
|
+
echo b >> $TEST_DIR/a.log
|
12
|
+
sleep 5
|
13
|
+
mv $TEST_DIR/a.log $TEST_DIR/b.log
|
14
|
+
sleep 5
|
15
|
+
echo c >> $TEST_DIR/b.log
|
16
|
+
sleep 3
|
17
|
+
|
18
|
+
test_done
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: tests file truncation
|
3
|
+
|
4
|
+
. $(dirname $0)/framework.sh
|
5
|
+
|
6
|
+
test_init
|
7
|
+
test_start
|
8
|
+
|
9
|
+
echo 1 > $TEST_DIR/a.log
|
10
|
+
echo 2 >> $TEST_DIR/a.log
|
11
|
+
echo 3 >> $TEST_DIR/a.log
|
12
|
+
sleep 3
|
13
|
+
echo 4 > $TEST_DIR/a.log
|
14
|
+
sleep 3
|
15
|
+
|
16
|
+
test_done
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: make sure we properly write a sincedb on SIGTERM, and pick up
|
3
|
+
# new log lines that were written while globtail is being restarted.
|
4
|
+
|
5
|
+
. $(dirname $0)/framework.sh
|
6
|
+
|
7
|
+
test_init
|
8
|
+
test_start
|
9
|
+
|
10
|
+
echo 1 > $TEST_DIR/a.log
|
11
|
+
echo 2 >> $TEST_DIR/a.log
|
12
|
+
echo 3 >> $TEST_DIR/a.log
|
13
|
+
sleep 6
|
14
|
+
|
15
|
+
echo 4 >> $TEST_DIR/a.log
|
16
|
+
test_stop
|
17
|
+
|
18
|
+
echo 5 >> $TEST_DIR/a.log
|
19
|
+
|
20
|
+
test_start
|
21
|
+
|
22
|
+
echo 6 >> $TEST_DIR/a.log
|
23
|
+
sleep 3
|
24
|
+
|
25
|
+
test_done
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: ensure sincedb periodic database writing works (make sure we're not
|
3
|
+
# relying on SIGTERM handling)
|
4
|
+
|
5
|
+
. $(dirname $0)/framework.sh
|
6
|
+
|
7
|
+
test_init
|
8
|
+
test_start
|
9
|
+
|
10
|
+
echo 1 > $TEST_DIR/a.log
|
11
|
+
echo 2 >> $TEST_DIR/a.log
|
12
|
+
echo 3 >> $TEST_DIR/a.log
|
13
|
+
sleep 8
|
14
|
+
|
15
|
+
echo 4 >> $TEST_DIR/a.log
|
16
|
+
sleep 3
|
17
|
+
|
18
|
+
# send a "kill -9" to test that the sincedb write interval stuff is working
|
19
|
+
kill -9 $TEST_TAIL_PID
|
20
|
+
test_stop
|
21
|
+
|
22
|
+
echo 5 >> $TEST_DIR/a.log
|
23
|
+
|
24
|
+
test_start
|
25
|
+
|
26
|
+
echo 6 >> $TEST_DIR/a.log
|
27
|
+
sleep 3
|
28
|
+
|
29
|
+
test_done
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: make sure a renamed file resumes it's since state
|
3
|
+
|
4
|
+
. $(dirname $0)/framework.sh
|
5
|
+
|
6
|
+
test_init
|
7
|
+
test_start
|
8
|
+
|
9
|
+
echo 1 > $TEST_DIR/a.log
|
10
|
+
echo 2 >> $TEST_DIR/a.log
|
11
|
+
echo 3 >> $TEST_DIR/a.log
|
12
|
+
sleep 6
|
13
|
+
|
14
|
+
test_stop
|
15
|
+
|
16
|
+
echo 4 >> $TEST_DIR/a.log
|
17
|
+
mv $TEST_DIR/a.log $TEST_DIR/b.log
|
18
|
+
|
19
|
+
test_start
|
20
|
+
|
21
|
+
echo 5 >> $TEST_DIR/b.log
|
22
|
+
sleep 3
|
23
|
+
|
24
|
+
test_done
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: sincedb, and file truncation between globtail runs
|
3
|
+
|
4
|
+
. $(dirname $0)/framework.sh
|
5
|
+
|
6
|
+
test_init
|
7
|
+
test_start
|
8
|
+
|
9
|
+
echo 1 > $TEST_DIR/a.log
|
10
|
+
echo 2 >> $TEST_DIR/a.log
|
11
|
+
echo 3 >> $TEST_DIR/a.log
|
12
|
+
sleep 8
|
13
|
+
|
14
|
+
test_stop
|
15
|
+
|
16
|
+
echo 4 > $TEST_DIR/a.log
|
17
|
+
|
18
|
+
test_start
|
19
|
+
|
20
|
+
echo 5 >> $TEST_DIR/a.log
|
21
|
+
sleep 3
|
22
|
+
|
23
|
+
test_done
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Test: exclude support
|
3
|
+
|
4
|
+
. $(dirname $0)/framework.sh
|
5
|
+
|
6
|
+
test_init
|
7
|
+
test_start
|
8
|
+
|
9
|
+
echo a1 > $TEST_DIR/a.log
|
10
|
+
echo b1 > $TEST_DIR/b.log
|
11
|
+
echo nope1 > $TEST_DIR/skip1.log
|
12
|
+
|
13
|
+
sleep 8
|
14
|
+
|
15
|
+
mv $TEST_DIR/b.log $TEST_DIR/skip2.log
|
16
|
+
echo b2 > $TEST_DIR/b.log
|
17
|
+
sleep 8
|
18
|
+
|
19
|
+
echo nope2 >> $TEST_DIR/skip2.log
|
20
|
+
sleep 3
|
21
|
+
|
22
|
+
test_done
|
metadata
CHANGED
@@ -1,62 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filewatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordan Sissel
|
14
|
+
- Pete Fritchman
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-04
|
19
|
+
date: 2011-09-04 00:00:00 -07:00
|
19
20
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
33
|
-
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
description: Watch files and directories in ruby. Also supports tailing and glob file patterns. Works with plain ruby, EventMachine, and JRuby
|
36
|
-
email: jls@semicomplete.com
|
21
|
+
dependencies: []
|
22
|
+
|
23
|
+
description: Watch files and directories in ruby. Also supports tailing and glob file patterns.
|
24
|
+
email:
|
25
|
+
- jls@semicomplete.com
|
26
|
+
- petef@databits.net
|
37
27
|
executables:
|
38
|
-
-
|
28
|
+
- globtail
|
39
29
|
extensions: []
|
40
30
|
|
41
31
|
extra_rdoc_files: []
|
42
32
|
|
43
33
|
files:
|
44
|
-
- lib/filewatch/
|
34
|
+
- lib/filewatch/buftok.rb
|
45
35
|
- lib/filewatch/watch.rb
|
46
|
-
- lib/filewatch/tailglob.rb
|
47
|
-
- lib/filewatch/namespace.rb
|
48
36
|
- lib/filewatch/tail.rb
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
- test/
|
57
|
-
- test/
|
58
|
-
- test/
|
59
|
-
-
|
37
|
+
- test/globtail/test5.data
|
38
|
+
- test/globtail/test7.sh
|
39
|
+
- test/globtail/test3.sh
|
40
|
+
- test/globtail/test2.data
|
41
|
+
- test/globtail/test3.data
|
42
|
+
- test/globtail/test6.sh
|
43
|
+
- test/globtail/test1.data
|
44
|
+
- test/globtail/Makefile
|
45
|
+
- test/globtail/test10.sh
|
46
|
+
- test/globtail/test4.data
|
47
|
+
- test/globtail/framework.sh
|
48
|
+
- test/globtail/test1.sh
|
49
|
+
- test/globtail/test8.sh
|
50
|
+
- test/globtail/test7.data
|
51
|
+
- test/globtail/test8.data
|
52
|
+
- test/globtail/test9.data
|
53
|
+
- test/globtail/test9.sh
|
54
|
+
- test/globtail/test5.sh
|
55
|
+
- test/globtail/test10.data
|
56
|
+
- test/globtail/test2.sh
|
57
|
+
- test/globtail/test4.sh
|
58
|
+
- test/globtail/test6.data
|
59
|
+
- bin/globtail
|
60
60
|
has_rdoc: true
|
61
61
|
homepage: https://github.com/jordansissel/ruby-filewatch
|
62
62
|
licenses: []
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
requirements: []
|
89
89
|
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.6.
|
91
|
+
rubygems_version: 1.6.2
|
92
92
|
signing_key:
|
93
93
|
specification_version: 3
|
94
94
|
summary: filewatch - file watching for ruby
|