blob: 290eb1d28b55fe64fa406f4084e5c5ff2ec03f5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#
# dbiff.rb - distributed cdbiff (server)
# * original: cdbiff by Satoru Takabayashi <http://namazu.org/~satoru/cdbiff>
require 'drb/drb'
require 'drb/eq'
require 'drb/observer'
class Biff
include DRb::DRbObservable
def initialize(filename, interval)
super()
@filename = filename
@interval = interval
end
def run
last = Time.now
while true
begin
sleep(@interval)
current = File::mtime(@filename)
if current > last
changed
begin
notify_observers(@filename, current)
rescue Error
end
last = current
end
rescue
next
end
end
end
end
def main
filename = "/var/mail/#{ENV['USER']}"
interval = 15
uri = 'druby://:19903'
biff = Biff.new(filename, interval)
DRb.start_service(uri, biff)
biff.run
end
main
|