/usr/share/doc/ruby1.8-examples/examples/drb/dbiff.rb is in ruby1.8-examples 1.8.7.352-2ubuntu1.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #
# 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
|